Skip to content
Discussion options

You must be logged in to vote

You don't need a custom component to do this, you just need to add the ner component from one pipeline to another, which you can do with nlp.add_pipe(source=):

import spacy
nlp_en = spacy.load("en_core_web_sm")
nlp_xx = spacy.load("xx_ent_wiki_sm")
nlp_en.add_pipe("ner", name="ner_xx", source=nlp_xx)
doc = nlp_en(text)
print(doc.ents)  # (Jane, Brussels, Santos Carlos, Brasil)

You have to give the new component a custom name because there's already a pipeline component named ner in the pipeline.

Note that the order of the ner components matters. The second ner component will only add entities where the first component has not added any entities.

There's a demo project tutorials/ner_double

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Singhal-harsh
Comment options

@Singhal-harsh
Comment options

@adrianeboyd
Comment options

@Singhal-harsh
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 / ner Feature: Named Entity Recognizer feat / pipeline Feature: Processing pipeline and components
2 participants