Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a moveprune operation which prunes an empty node if needed after … #1263

Merged
merged 6 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/edu/stanford/nlp/trees/tregex/DescriptionPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class DescriptionPattern extends TregexPattern {
private static Redwood.RedwoodChannels log = Redwood.channels(DescriptionPattern.class);

enum DescriptionMode {
PATTERN, STRINGS, EXACT, ANYTHING
PATTERN, STRINGS, EXACT, ANYTHING, ROOT
}

private final Relation rel;
Expand Down Expand Up @@ -77,6 +77,11 @@ public DescriptionPattern(Relation rel, boolean negDesc, String desc,
descPattern = null;
exactMatch = null;
stringFilter = null;
} else if (desc.equals("_ROOT_")) {
descriptionMode = DescriptionMode.ROOT;
descPattern = null;
exactMatch = null;
stringFilter = null;
} else if (SINGLE_WORD_PATTERN.matcher(desc).matches()) {
// Expressions are written like this to put special characters
// in the tregex matcher, but a regular expression is less
Expand Down Expand Up @@ -403,6 +408,9 @@ private void goToNextTreeNodeMatch() {
case STRINGS:
found = myNode.stringFilter.test(value);
break;
case ROOT:
found = (nextTreeNodeMatchCandidate == root);
break;
default:
throw new IllegalArgumentException("Unexpected match mode");
}
Expand Down