From da086643647907da3cce036ba0c389f078a90342 Mon Sep 17 00:00:00 2001 From: John Bauer Date: Wed, 7 Dec 2022 17:13:40 -0800 Subject: [PATCH] If the entitymentions annotator ran (indicated by MentionsAnnotation being set), return an empty list of entityMentions for an empty document. Addresses #1322 --- src/edu/stanford/nlp/pipeline/CoreDocument.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/edu/stanford/nlp/pipeline/CoreDocument.java b/src/edu/stanford/nlp/pipeline/CoreDocument.java index a365195a55..de01d39c1e 100644 --- a/src/edu/stanford/nlp/pipeline/CoreDocument.java +++ b/src/edu/stanford/nlp/pipeline/CoreDocument.java @@ -33,8 +33,10 @@ public void wrapAnnotations() { if (this.annotationDocument.get(CoreAnnotations.SentencesAnnotation.class) != null) { wrapSentences(); // if there are entity mentions, build a document wide list - if ( ! sentences.isEmpty() && sentences.get(0).entityMentions() != null) { + if (!sentences.isEmpty() && sentences.get(0).entityMentions() != null) { buildDocumentEntityMentionsList(); + } else if (annotationDocument.get(CoreAnnotations.MentionsAnnotation.class) != null) { + entityMentions = Collections.emptyList(); } // if there are quotes, build a document wide list if (QuoteAnnotator.gatherQuotes(this.annotationDocument) != null)