From 605f4a588b2f53110d437f4d6274811a6c54f023 Mon Sep 17 00:00:00 2001 From: John Bauer Date: Fri, 13 Oct 2023 08:59:04 -0700 Subject: [PATCH] Throws a more descriptive NPE if a token comes back null, as that will eventually crash anyway --- .../stanford/nlp/pipeline/ProtobufAnnotationSerializer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java b/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java index d270c48a0c..ecfd7ce447 100644 --- a/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java +++ b/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java @@ -2418,6 +2418,9 @@ private static SemanticGraph fromProto(CoreNLPProtos.DependencyGraph proto, List } else { // TODO: index based on emptyIndex as well token = originalLabels.get(in.getIndex(), 0); + if (token == null) { + throw new NullPointerException("Could not find the token for index " + in.getIndex()); + } } IndexedWord word; if (in.hasCopyAnnotation() && in.getCopyAnnotation() > 0) {