Skip to content

Commit

Permalink
Use spans_ prefix for default span finder scores (#12753)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianeboyd authored Jun 27, 2023
1 parent 65f6c9c commit 337a360
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions spacy/pipeline/span_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
"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(
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions spacy/tests/pipeline/test_span_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 337a360

Please sign in to comment.