mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-10 19:57:17 +03:00
Use spans_ prefix for default span finder scores (#12753)
This commit is contained in:
parent
65f6c9cd10
commit
337a360cc7
|
@ -53,9 +53,9 @@ DEFAULT_SPAN_FINDER_MODEL = Config().from_str(span_finder_default_config)["model
|
|||
"scorer": {"@scorers": "spacy.span_finder_scorer.v1"},
|
||||
},
|
||||
default_score_weights={
|
||||
f"span_finder_{DEFAULT_SPANS_KEY}_f": 1.0,
|
||||
f"span_finder_{DEFAULT_SPANS_KEY}_p": 0.0,
|
||||
f"span_finder_{DEFAULT_SPANS_KEY}_r": 0.0,
|
||||
f"spans_{DEFAULT_SPANS_KEY}_f": 1.0,
|
||||
f"spans_{DEFAULT_SPANS_KEY}_p": 0.0,
|
||||
f"spans_{DEFAULT_SPANS_KEY}_r": 0.0,
|
||||
},
|
||||
)
|
||||
def make_span_finder(
|
||||
|
@ -104,7 +104,7 @@ def make_span_finder_scorer():
|
|||
|
||||
def span_finder_score(examples: Iterable[Example], **kwargs) -> Dict[str, Any]:
|
||||
kwargs = dict(kwargs)
|
||||
attr_prefix = "span_finder_"
|
||||
attr_prefix = "spans_"
|
||||
key = kwargs["spans_key"]
|
||||
kwargs.setdefault("attr", f"{attr_prefix}{key}")
|
||||
kwargs.setdefault(
|
||||
|
|
|
@ -230,10 +230,10 @@ def test_overfitting_IO():
|
|||
|
||||
# Test scoring
|
||||
scores = nlp.evaluate(train_examples)
|
||||
assert f"span_finder_{SPANS_KEY}_f" in scores
|
||||
assert f"spans_{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_{SPANS_KEY}_p"] == 0.75
|
||||
assert scores[f"span_finder_{SPANS_KEY}_r"] == 1.0
|
||||
assert scores[f"spans_{SPANS_KEY}_p"] == 0.75
|
||||
assert scores[f"spans_{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