PhraseMatcher persistance issue #5493
-
Feature descriptionI create a PhraseMatcher and in the process use nlp = spacy.blank('en') model to create doc objects of patterns. The phrasematcher works well. I save PhraseMatcher in pickle format and load the pickle file and because PhraseMatcher needs doc I use nlp = spacy.blank('en') to create a doc object but Phrasematcher returns empty list. How do I persist PhraseMatcher so that I can anytime load it and match phrases without learning patterns from scratch. Could the feature be a custom component or spaCy plugin?If so, we will tag it as |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
It works when I persist both PhraseMatcher and nlp together
|
Beta Was this translation helpful? Give feedback.
-
Hi, after unpickling the PhraseMatcher, I think the missing step is to initialize your new nlp pipeline with the same vocab like this:
|
Beta Was this translation helpful? Give feedback.
-
Thanks @adrianeboyd |
Beta Was this translation helpful? Give feedback.
Hi, after unpickling the PhraseMatcher, I think the missing step is to initialize your new nlp pipeline with the same vocab like this: