Skip to content

Commit 87fe2ef

Browse files
committed
use the get which returns null instead of throwing
1 parent 2341d33 commit 87fe2ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/edu/stanford/nlp/trees/ud/CoNLLUDocumentWriter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public String printSemanticGraph(SemanticGraph basicSg, SemanticGraph enhancedSg
101101

102102
// don't use after() directly; it returns a default of ""
103103
if (token.get(CoreAnnotations.AfterAnnotation.class) != null && token.after().equals("")) {
104-
IndexedWord nextVertex = tokenSg.getNodeByIndex(token.index() + 1);
104+
IndexedWord nextVertex = tokenSg.getNodeByIndexSafe(token.index() + 1);
105105
// the next word needs to exist and be part of the same MWT
106106
// and either this word is the start of the MWT
107107
// 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
182182
// advance endIndex until we reach the end of the sentence, the start of the next MWT,
183183
// or a word which isn't part of any MWT
184184
IndexedWord nextVertex;
185-
while ((nextVertex = graph.getNodeByIndex(endIndex+1)) != null) {
185+
while ((nextVertex = graph.getNodeByIndexSafe(endIndex+1)) != null) {
186186
if (!isMWTbutNotStart(nextVertex)) {
187187
break;
188188
}

0 commit comments

Comments
 (0)