Apply suggestions from code review

This commit is contained in:
Adriane Boyd 2023-06-02 11:52:21 +02:00 committed by GitHub
parent a33c7e0144
commit 3abdca27e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 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,7 +251,7 @@ 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