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.
This commit is contained in:
Paul O'Leary McCann 2021-07-14 18:19:00 +09:00
parent 80a17071d3
commit f1796e4af7

View File

@ -128,7 +128,8 @@ def get_candidate_mentions(
si = sentence_map[tok.i] # sentence index si = sentence_map[tok.i] # sentence index
for ii in range(1, max_span_width): for ii in range(1, max_span_width):
ei = tok.i + ii # end index 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 continue
begins.append(tok.i) begins.append(tok.i)