Skip to content
Discussion options

You must be logged in to vote

Ok, upon investigating #10674, @adrianeboyd links to https://github.com/explosion/projects/tree/v3/tutorials/ner_double and I see a curious: drug_nlp.replace_listeners("tok2vec", "ner", ["model.tok2vec"]). Didn't know this was a necessary step so I tried it and it solves my problem. Thank you!

_model = spacy.load("./models/statutes/model-best")
_model.pipe_names
# ['tok2vec', 'ner']
# adapted from solution
_model.replace_listeners("tok2vec", "ner", ["model.tok2vec"]) 
# reuse same code above
x = spacy.blank("en")
x.add_pipe("ner", name="statute_ner", source=_model)
x.pipe_names
# ['statute_ner']
doc = x('Section 13 of PD No. 1869 provides xxx')
for e in doc.ents:
  print(f"{e.text=} {e.la…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rmitsch
Comment options

Answer selected by justmars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usage General spaCy usage feat / pipeline Feature: Processing pipeline and components
2 participants