Closed mirfan899 closed 3 years ago
got it working with spacy 3.
@mirfan899 what fixed the issue?
import spacy
from ewiser.spacy.disambiguate import Disambiguator
from spacy.language import Language
nlp = spacy.load("en_core_web_sm", disable=['parser', 'ner'])
@Language.factory('wsd')
def wsd_engine(nlp, name):
return Disambiguator('ewiser/ewiser.semcor+wngt.pt', lang="en")
nlp.add_pipe('wsd', last=True)
doc = nlp("I want the peach cobbler.")
for w in doc:
if w._.offset:
print(w.text, w.lemma_, w.pos_, w._.offset, w._.synset.definition())
@LifeIsStrange Here you go. It's a simple trick for spaCy 3 requirements. @mbevila It'd be great if we also modified the code in disambiguate.py. By the way, is there a way to see sense keys?
I tried to use spacy 3 but it gives an error.