Skip to content

Commit

Permalink
Return 500 if the server doesn't have parse annotator and tregex is c…
Browse files Browse the repository at this point in the history
…alled
  • Loading branch information
AngledLuffa committed Mar 16, 2022
1 parent 44fa4d9 commit 4db80c0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java
Expand Up @@ -1348,6 +1348,9 @@ public void handle(HttpExchange httpExchange) throws IOException {
docWriter.set("sentences", doc.get(CoreAnnotations.SentencesAnnotation.class).stream().map(sentence -> (Consumer<JSONOutputter.Writer>) (JSONOutputter.Writer sentWriter) -> {
int sentIndex = sentence.get(CoreAnnotations.SentenceIndexAnnotation.class);
Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);
if (tree == null) {
throw new IllegalStateException("Error: cannot process tregex operations with no constituency tree annotations. Perhaps need to reinitialize the server with the parse annotator");
}
//sentWriter.set("tree", tree.pennString());
TregexMatcher matcher = p.matcher(tree);

Expand Down

0 comments on commit 4db80c0

Please sign in to comment.