From f1796e4af7d6f875a0d38126c6bfbfd21aa7a6f1 Mon Sep 17 00:00:00 2001 From: Paul O'Leary McCann Date: Wed, 14 Jul 2021 18:19:00 +0900 Subject: [PATCH] Fix mention list bug There was an off-by-one error in how mentions are generated that would affect mentions at the end of a sentence. This was pretty nasty. --- spacy/ml/models/coref_util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/ml/models/coref_util.py b/spacy/ml/models/coref_util.py index b0a632bd8..74bfbf6f0 100644 --- a/spacy/ml/models/coref_util.py +++ b/spacy/ml/models/coref_util.py @@ -128,7 +128,8 @@ def get_candidate_mentions( si = sentence_map[tok.i] # sentence index for ii in range(1, max_span_width): ei = tok.i + ii # end index - if ei >= len(doc) or sentence_map[ei] != si: + # Note: this matches slice syntax, so the token index is one less + if ei > len(doc) or sentence_map[ei-1] != si: continue begins.append(tok.i)