Merge branch 'add-span-finder' of https://github.com/kadarakos/spaCy into add-span-finder

This commit is contained in:
kadarakos 2023-06-02 10:01:19 +00:00
commit 3ec1cb5e30
2 changed files with 5 additions and 3 deletions

View File

@ -107,7 +107,9 @@ def span_finder_score(examples: Iterable[Example], **kwargs) -> Dict[str, Any]:
"getter", lambda doc, key: doc.spans.get(key[len(attr_prefix) :], [])
)
kwargs.setdefault("has_annotation", lambda doc: key in doc.spans)
return Scorer.score_spans(examples, **kwargs)
scores = Scorer.score_spans(examples, **kwargs)
scores.pop(f"{kwargs['attr']}_per_type", None)
return scores
class _MaxInt(int):

View File

@ -135,7 +135,6 @@ def test_span_finder_component():
nlp.initialize()
docs = list(span_finder.pipe(docs))
# TODO: update hard-coded name
assert SPANS_KEY in docs[0].spans
@ -252,8 +251,9 @@ def test_overfitting_IO():
# Test scoring
scores = nlp.evaluate(train_examples)
assert f"span_finder_{span_finder.spans_key}_f" in scores
# XXX Its not perfect 1.0 F1 because we want it to overgenerate for now.
# 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}_r"] == 1.0
# also test that the spancat works for just a single entity in a sentence
doc = nlp("London")