From 56de1076a1497c2f3a61ad87ce628feeadf23107 Mon Sep 17 00:00:00 2001 From: kadarakos Date: Thu, 1 Jun 2023 17:40:25 +0200 Subject: [PATCH] Update spacy/pipeline/span_finder.py Co-authored-by: Adriane Boyd --- spacy/pipeline/span_finder.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/spacy/pipeline/span_finder.py b/spacy/pipeline/span_finder.py index a9874f724..ba023c6c0 100644 --- a/spacy/pipeline/span_finder.py +++ b/spacy/pipeline/span_finder.py @@ -272,21 +272,13 @@ class SpanFinder(TrainablePipe): pred_start_char, pred_end_char = _char_indices(pred_span) start_match = pred_start_char == ref_start_char end_match = pred_end_char == ref_end_char - # Tokenizations line up. - if start_match and end_match: + if start_match: truth[pred_span[0].i, 0] = 1 - truth[pred_span[-1].i, 1] = 1 - # Start character index lines up, but not the end. - elif start_match and not end_match: - truth[pred_span[0].i, 0] = 1 - mask[pred_span[-1].i, 1] = 0 - # End character index lines up, but not the start. - elif not start_match and end_match: - truth[pred_span[-1].i, 1] = 1 - mask[pred_span[0].i, 0] = 0 - # Neither of them match. else: mask[pred_span[0].i, 0] = 0 + if end_match: + truth[pred_span[-1].i, 1] = 1 + else: mask[pred_span[-1].i, 1] = 0 truths.append(truth) masks.append(mask)