Integrate Entity Ruler with Span Marker model #12912
ralucaginga
started this conversation in
Help: Best practices
Replies: 1 comment
-
Hi @ralucaginga, have you tried running the entity ruler after SpanMarker? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi. I would like to mix up both the Span Marker model with Spacy integration(https://spacy.io/universe/project/span_marker) and the entity ruler (to add some custom patterns), similar like in the code from below.
`
import spacy
import de_dep_news_trf
nlp = de_dep_news_trf.load()
patterns = [{"label": "PERIOD", "pattern": [{"LOWER": "monat"}]},
{"label": "PER", "pattern": "Raluca"},
{"label": "COLOR", "pattern": [{"LOWER": "blau"}]},
{"label": "JOBTITLE", "pattern": [{"LOWER" : {"REGEX": ".(referent)."}}]}
]
ruler = nlp.add_pipe("entity_ruler")
ruler.add_patterns(patterns)
span_marker_ruler = nlp.add_pipe('span_marker', config={"model": "tomaarsen/span-marker-mbert-base-multinerd"}, name='span_marker_ruler')
doc = nlp("Raluca ist referent, er mag die Farbe Blau und geht jeden Monat in die Berge.")
print([(ent.text, ent.label_) for ent in doc.ents])
`
Unfortunately, this mix doesn't work properly.
I would expect however an output like this
[('Raluca', 'PER'), ('referent', 'JOBTITLE'), ('Blau', 'COLOR'), ('Monat', 'PERIOD')]
How to integrate entity ruler (with add of some customized entities and patterns) with the Span Marker model?
Beta Was this translation helpful? Give feedback.
All reactions