SapienzaNLP / ewiser

A Word Sense Disambiguation system integrating implicit and explicit external knowledge.
Other
66 stars 17 forks source link

Spacy 3 not compatible #12

Closed mirfan899 closed 3 years ago

mirfan899 commented 3 years ago

I tried to use spacy 3 but it gives an error.

ewiser

mirfan899 commented 3 years ago

got it working with spacy 3.

LifeIsStrange commented 2 years ago

@mirfan899 what fixed the issue?

brucewlee commented 2 years ago
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())
brucewlee commented 2 years ago

@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?