diff --git a/src/edu/stanford/nlp/trees/ud/CoNLLUDocumentWriter.java b/src/edu/stanford/nlp/trees/ud/CoNLLUDocumentWriter.java index e9892424ce..02a3ef7748 100644 --- a/src/edu/stanford/nlp/trees/ud/CoNLLUDocumentWriter.java +++ b/src/edu/stanford/nlp/trees/ud/CoNLLUDocumentWriter.java @@ -101,7 +101,7 @@ public String printSemanticGraph(SemanticGraph basicSg, SemanticGraph enhancedSg // don't use after() directly; it returns a default of "" if (token.get(CoreAnnotations.AfterAnnotation.class) != null && token.after().equals("")) { - IndexedWord nextVertex = tokenSg.getNodeByIndex(token.index() + 1); + IndexedWord nextVertex = tokenSg.getNodeByIndexSafe(token.index() + 1); // the next word needs to exist and be part of the same MWT // and either this word is the start of the MWT // or this word is the middle of the same MWT as the next word @@ -182,7 +182,7 @@ public static void printMWT(StringBuilder sb, SemanticGraph graph, IndexedWord t // advance endIndex until we reach the end of the sentence, the start of the next MWT, // or a word which isn't part of any MWT IndexedWord nextVertex; - while ((nextVertex = graph.getNodeByIndex(endIndex+1)) != null) { + while ((nextVertex = graph.getNodeByIndexSafe(endIndex+1)) != null) { if (!isMWTbutNotStart(nextVertex)) { break; }