Skip to content
Discussion options

You must be logged in to vote

Ahh it's probably intended. Instead I should not overwrite but replace the ents_filter with {"@misc": "spacy.prioritize_new_ents_filter.v1"}

The following works

import spacy

text = "Apple is opening its first big office in San Francisco."
nlp = spacy.blank("en")
ruler = nlp.add_pipe(
    "span_ruler", config={"validate": True, "spans_key": None, "annotate_ents": True}
)
patterns = [
    {"label": "ORG", "pattern": "Apple"},
    {"label": "GPE", "pattern": [{"LOWER": "san"}, {"LOWER": "francisco"}]},
]
ruler.add_patterns(patterns)
assert len(nlp(text).ents) == 2

ruler2 = nlp.add_pipe(
    "span_ruler",
    name="span_ruler2",
    config={
        "validate": True,
        "spans_key": None

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@adrianeboyd
Comment options

@NixBiks
Comment options

@adrianeboyd
Comment options

Answer selected by adrianeboyd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat / spanruler Feature: Entity and span ruler
2 participants