bjascob / LemmInflect

A python module for English lemmatization and inflection.
MIT License
258 stars 25 forks source link

Doc Enhancement #10

Closed hasandiwan closed 3 years ago

hasandiwan commented 3 years ago

spacy.load("en_core_websm")(word)[0]..inflect("NNS")

gives me "Can't retrieve unregistered extension attribute 'inflect'. Did you forget to call the set_extension method?".

If I follow the message and add "spacy.tokens.Token.set_extension('inflect', method=Inflections().spacyGetInfl)", I now get " Extension 'inflect' already exists on Token. To overwrite the existing extension, set force=True on Token.set_extension"

If I add force=True, it gives me what I want, but there's no mention of this in the tests.

If you'd like, I can add a test to this extent or a note in the README.

bjascob commented 3 years ago

This works for me. The only way I can see to get this to happen is if someone forget to import lemminflect
lemminflect.__init__.py has code to set the hooks into spaCy which is called when you import.

>>> import spacy
>>> import lemminflect
>>> spacy.load("en_core_web_sm")('test this')[0]._.inflect("NNS")
'tests'

This above works. If this doesn't for you, please give me the version of spaCy, os, etc.. and exactly the commands you're running.