|
138 | 138 | * {@code ...attributes...} are the attributes to change, same as with {@code addDep}
|
139 | 139 | * {@code -morphofeatures ...} will set the features to be exactly as written.
|
140 | 140 | * {@code -updateMorphoFeatures ...} will edit or add the features without overwriting existing features.
|
141 |
| - * TODO: if anyone needs the ability to remove features without resetting the entire features map, |
142 |
| - * please file an issue on github. |
| 141 | + * {@code -removeMorphoFeatures ...} will remove this one morpho feature. |
143 | 142 | * {@code -remove ...} will remove the attribute entirely, such as doing {@code -remove lemma} to remove the lemma.
|
144 | 143 | *</p><p>
|
145 | 144 | * {@code lemmatize} will put a lemma on a word.
|
|
230 | 229 | addDep -gov antennae -reln dep -word blue
|
231 | 230 | }
|
232 | 231 | </pre>
|
| 232 | + * Some patterns which leave the node in the same format will bomb because of the way the dirty bit works. For example: |
| 233 | +<pre> |
| 234 | +{@code |
| 235 | +{word:/pattern/;cpos:VERB;morphofeatures:{VerbForm:Inf}}=word |
| 236 | +EditNode -node word -remove morphofeatures |
| 237 | +EditNode -node word -updatemorphofeatures Aspect=Imp -updatemorphofeatures VerbForm=Inf |
| 238 | +} |
| 239 | +</pre> |
| 240 | + * Here, the end result will be the same after at most one iteration through the loop, |
| 241 | + * but {@code -remove morphofeatures} sets the dirty bit and does not go away |
| 242 | + * when {@code -updatemorphofeatures} puts back the deleted features. |
| 243 | + * TODO: this one at least can be fixed |
233 | 244 | *
|
234 | 245 | * @author Eric Yeh
|
235 | 246 | */
|
@@ -420,6 +431,7 @@ public Collection<SsurgeonWordlist> getResources() {
|
420 | 431 | public static final String UPDATE_MORPHO_FEATURES = "-updateMorphoFeatures";
|
421 | 432 | public static final String UPDATE_MORPHO_FEATURES_LOWER = "-updatemorphofeatures";
|
422 | 433 | public static final String REMOVE = "-remove";
|
| 434 | + public static final String REMOVE_MORPHO_FEATURES = "-removeMorphoFeatures"; |
423 | 435 |
|
424 | 436 |
|
425 | 437 | // args for Ssurgeon edits, allowing us to not
|
@@ -454,6 +466,8 @@ protected static class SsurgeonArgs {
|
454 | 466 | public Map<String, String> annotations = new TreeMap<>();
|
455 | 467 |
|
456 | 468 | public List<String> remove = new ArrayList<>();
|
| 469 | + |
| 470 | + public List<String> removeMorphoFeatures = new ArrayList<>(); |
457 | 471 | }
|
458 | 472 |
|
459 | 473 | /**
|
@@ -537,6 +551,9 @@ private static SsurgeonArgs parseArgsBox(String args, Map<String, String> additi
|
537 | 551 | case REMOVE:
|
538 | 552 | argsBox.remove.add(argsValue);
|
539 | 553 | break;
|
| 554 | + case REMOVE_MORPHO_FEATURES: |
| 555 | + argsBox.removeMorphoFeatures.add(argsValue); |
| 556 | + break; |
540 | 557 | default:
|
541 | 558 | String key = argsKey.substring(1);
|
542 | 559 | Class<? extends CoreAnnotation<?>> annotation = AnnotationLookup.toCoreKey(key);
|
@@ -602,7 +619,7 @@ public static SsurgeonEdit parseEditLine(String editLine, Map<String, String> at
|
602 | 619 | if (argsBox.nodes.size() != 1) {
|
603 | 620 | throw new SsurgeonParseException("Cannot make an EditNode out of " + argsBox.nodes.size() + " nodes. Please use exactly one -node");
|
604 | 621 | }
|
605 |
| - return new EditNode(argsBox.nodes.get(0), argsBox.annotations, argsBox.updateMorphoFeatures, argsBox.remove); |
| 622 | + return new EditNode(argsBox.nodes.get(0), argsBox.annotations, argsBox.updateMorphoFeatures, argsBox.remove, argsBox.removeMorphoFeatures); |
606 | 623 | } else if (command.equalsIgnoreCase(Lemmatize.LABEL)) {
|
607 | 624 | if (argsBox.nodes.size() != 1) {
|
608 | 625 | throw new SsurgeonParseException("Cannot make a Lemmatize out of " + argsBox.nodes.size() + " nodes. Please use exactly one -node");
|
|
0 commit comments