mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-03 20:00:21 +03:00
Merge branch 'add-span-finder' of https://github.com/kadarakos/spaCy into add-span-finder
This commit is contained in:
commit
3ec1cb5e30
|
@ -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):
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user