mirror of
https://github.com/explosion/spaCy.git
synced 2025-04-21 17:41:59 +03:00
Update spacy/pipeline/span_finder.py
Co-authored-by: Adriane Boyd <adrianeboyd@gmail.com>
This commit is contained in:
parent
8c7c34d4f4
commit
56de1076a1
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user