mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-04 04:10:20 +03:00
Fix offset bug in set_annotations
* Ignore labels in span finder scorer
This commit is contained in:
parent
f84b59d68a
commit
bb62ee9450
|
@ -111,6 +111,7 @@ def span_finder_score(examples: Iterable[Example], **kwargs) -> Dict[str, Any]:
|
|||
)
|
||||
kwargs.setdefault("has_annotation", lambda doc: key in doc.spans)
|
||||
kwargs.setdefault("allow_overlap", True)
|
||||
kwargs.setdefault("labeled", False)
|
||||
scores = Scorer.score_spans(examples, **kwargs)
|
||||
scores.pop(f"{kwargs['attr']}_per_type", None)
|
||||
return scores
|
||||
|
@ -215,6 +216,7 @@ class SpanFinder(TrainablePipe):
|
|||
break
|
||||
elif self.min_length <= span_length:
|
||||
doc.spans[self.spans_key].append(doc[start : end + 1])
|
||||
offset += len(doc)
|
||||
|
||||
def update(
|
||||
self,
|
||||
|
|
|
@ -234,7 +234,7 @@ def test_overfitting_IO():
|
|||
scores = nlp.evaluate(train_examples)
|
||||
assert f"span_finder_{span_finder.spans_key}_f" in scores
|
||||
# It's not perfect 1.0 F1 because it's designed to overgenerate for now.
|
||||
assert scores[f"span_finder_{span_finder.spans_key}_f"] == 0.4
|
||||
assert scores[f"span_finder_{span_finder.spans_key}_p"] == 0.75
|
||||
assert scores[f"span_finder_{span_finder.spans_key}_r"] == 1.0
|
||||
|
||||
# also test that the spancat works for just a single entity in a sentence
|
||||
|
|
Loading…
Reference in New Issue
Block a user