Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Loading