Skip to content

Commit 4db80c0

Browse files
committed
Return 500 if the server doesn't have parse annotator and tregex is called
1 parent 44fa4d9 commit 4db80c0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java

+3
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,9 @@ public void handle(HttpExchange httpExchange) throws IOException {
13481348
docWriter.set("sentences", doc.get(CoreAnnotations.SentencesAnnotation.class).stream().map(sentence -> (Consumer<JSONOutputter.Writer>) (JSONOutputter.Writer sentWriter) -> {
13491349
int sentIndex = sentence.get(CoreAnnotations.SentenceIndexAnnotation.class);
13501350
Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);
1351+
if (tree == null) {
1352+
throw new IllegalStateException("Error: cannot process tregex operations with no constituency tree annotations. Perhaps need to reinitialize the server with the parse annotator");
1353+
}
13511354
//sentWriter.set("tree", tree.pennString());
13521355
TregexMatcher matcher = p.matcher(tree);
13531356

0 commit comments

Comments
 (0)