Skip to content

Commit

Permalink
use the get which returns null instead of throwing
Browse files Browse the repository at this point in the history
  • Loading branch information
AngledLuffa committed Nov 28, 2024
1 parent 2341d33 commit 87fe2ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/edu/stanford/nlp/trees/ud/CoNLLUDocumentWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 87fe2ef

Please sign in to comment.