diff --git a/spacy/pipeline/attributeruler.py b/spacy/pipeline/attributeruler.py index 2cb28cc91..cc1e2e37a 100644 --- a/spacy/pipeline/attributeruler.py +++ b/spacy/pipeline/attributeruler.py @@ -43,7 +43,6 @@ def attribute_ruler_score(examples: Iterable[Example], **kwargs) -> Dict[str, An return results -@registry.scorers("spacy.attribute_ruler_scorer.v1") def make_attribute_ruler_scorer(): return attribute_ruler_score diff --git a/spacy/pipeline/entity_linker.py b/spacy/pipeline/entity_linker.py index 347874970..6a1ed11df 100644 --- a/spacy/pipeline/entity_linker.py +++ b/spacy/pipeline/entity_linker.py @@ -46,7 +46,6 @@ def entity_linker_score(examples, **kwargs): return Scorer.score_links(examples, negative_labels=[EntityLinker.NIL], **kwargs) -@registry.scorers("spacy.entity_linker_scorer.v1") def make_entity_linker_scorer(): return entity_linker_score diff --git a/spacy/pipeline/span_ruler.py b/spacy/pipeline/span_ruler.py index 763766536..98287ba1d 100644 --- a/spacy/pipeline/span_ruler.py +++ b/spacy/pipeline/span_ruler.py @@ -60,7 +60,6 @@ def prioritize_new_ents_filter( return entities + new_entities -@registry.misc("spacy.prioritize_new_ents_filter.v1") def make_prioritize_new_ents_filter(): return prioritize_new_ents_filter @@ -91,7 +90,6 @@ def prioritize_existing_ents_filter( return entities + new_entities -@registry.misc("spacy.prioritize_existing_ents_filter.v1") def make_preserve_existing_ents_filter(): return prioritize_existing_ents_filter @@ -111,7 +109,6 @@ def overlapping_labeled_spans_score( return Scorer.score_spans(examples, **kwargs) -@registry.scorers("spacy.overlapping_labeled_spans_scorer.v1") def make_overlapping_labeled_spans_scorer(spans_key: str = DEFAULT_SPANS_KEY): return partial(overlapping_labeled_spans_score, spans_key=spans_key) diff --git a/spacy/registrations.py b/spacy/registrations.py index 7485966a8..3133197c4 100644 --- a/spacy/registrations.py +++ b/spacy/registrations.py @@ -35,6 +35,14 @@ def populate_registry() -> None: build_preset_spans_suggester, make_spancat_scorer, ) + # Import the functions we refactored by removing direct registry decorators + from .pipeline.entity_linker import make_entity_linker_scorer + from .pipeline.span_ruler import ( + make_overlapping_labeled_spans_scorer, + make_prioritize_new_ents_filter, + make_preserve_existing_ents_filter, + ) + from .pipeline.attributeruler import make_attribute_ruler_scorer # Import all pipeline components that were using registry decorators from .pipeline.tagger import make_tagger_scorer @@ -49,6 +57,8 @@ def populate_registry() -> None: registry.misc("spacy.ngram_suggester.v1")(build_ngram_suggester) registry.misc("spacy.ngram_range_suggester.v1")(build_ngram_range_suggester) registry.misc("spacy.preset_spans_suggester.v1")(build_preset_spans_suggester) + registry.misc("spacy.prioritize_new_ents_filter.v1")(make_prioritize_new_ents_filter) + registry.misc("spacy.prioritize_existing_ents_filter.v1")(make_preserve_existing_ents_filter) # Need to get references to the existing functions in registry by importing the function that is there # For the registry that was previously decorated @@ -83,6 +93,9 @@ def populate_registry() -> None: registry.scorers("spacy.lemmatizer_scorer.v1")(make_lemmatizer_scorer) registry.scorers("spacy.span_finder_scorer.v1")(make_span_finder_scorer) registry.scorers("spacy.spancat_scorer.v1")(make_spancat_scorer) + registry.scorers("spacy.entity_linker_scorer.v1")(make_entity_linker_scorer) + registry.scorers("spacy.overlapping_labeled_spans_scorer.v1")(make_overlapping_labeled_spans_scorer) + registry.scorers("spacy.attribute_ruler_scorer.v1")(make_attribute_ruler_scorer) # Register tok2vec architectures we've modified registry.architectures("spacy.Tok2VecListener.v1")(tok2vec_listener_v1)