Skip to content

Commit

Permalink
Add a bit of error checking to RelabelNode to make an error a bit les…
Browse files Browse the repository at this point in the history
…s inscrutable
  • Loading branch information
AngledLuffa committed May 18, 2024
1 parent 375f243 commit bb4d17f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/edu/stanford/nlp/trees/tregex/tsurgeon/RelabelNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ public Tree evaluate(Tree tree, TregexMatcher tregex) {
label.append(Matcher.quoteReplacement(tregex.getVariableString(name)));
} else if (nodePattern.matcher(chunk).matches()) {
String name = chunk.substring(2, chunk.length() - 1);
label.append(Matcher.quoteReplacement(tregex.getNode(name).value()));
Tree node = tregex.getNode(name);
if (node == null) {
throw new NullPointerException("Node name " + name + " does not exist in the searched tree");
}
label.append(Matcher.quoteReplacement(node.value()));
} else {
label.append(chunk);
}
Expand Down

0 comments on commit bb4d17f

Please sign in to comment.