Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Entity Ruler with Span Marker model #25

Closed
ralucaginga opened this issue Aug 14, 2023 · 1 comment · Fixed by #16
Closed

Integrate Entity Ruler with Span Marker model #25

ralucaginga opened this issue Aug 14, 2023 · 1 comment · Fixed by #16

Comments

@ralucaginga
Copy link

ralucaginga commented Aug 14, 2023

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.
image

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?

Do you have any ideas on how to solve this kind of issues?

@tomaarsen tomaarsen linked a pull request Aug 24, 2023 that will close this issue
@tomaarsen
Copy link
Owner

In a few minutes you'll be able to install SpanMarker 1.3.0 and this will be fully supported. You won't have to make any changes to your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants