chrisjbryant / errant

ERRor ANnotation Toolkit: Automatically extract and classify grammatical errors in parallel original and corrected sentences.
MIT License
436 stars 107 forks source link

‘’AttributeError: 'English' object has no attribute 'tagger'” when running the "Quick Start" code in API given in README.md #38

Closed Yvonne-LOK closed 2 years ago

Yvonne-LOK commented 2 years ago

How can I eliminate this error report "AttributeError: 'English' object has no attribute 'tagger'"? I changed several data models, but they didn't work.

code: `import errant

annotator = errant.load('en') orig = annotator.parse('This are gramamtical sentence .') cor = annotator.parse('This is a grammatical sentence .') edits = annotator.annotate(orig, cor) for e in edits: print(e.o_start, e.o_end, e.o_str, e.c_start, e.c_end, e.c_str, e.type)`

chrisjbryant commented 2 years ago

Hiya,

Sounds like you forgot to install a spacy model (the last line in the installation instructions): python3 -m spacy download en

If that still doesn't work, try reinstalling in a new, clean virtual python environment.

Yvonne-LOK commented 2 years ago

Hi @chrisjbryant I install a new virtual python environmen and it works. Thank you so much! But I met another problem: "KeyError: "[E002] Can't find factory for 'tok2vec'. This usually happens when spaCy calls nlp.create_pipe with a component name that's not built in - for example, when constructing the pipeline from a model's meta.json. If you're using a custom component, you can write to Language.factories['tok2vec'] or remove it from the model meta and add it via nlp.add_pipe instead."

Is this because some files in my "en_core_web_md" model are not in the right place or something else?

chrisjbryant commented 2 years ago

Glad to hear it works! That other error sounds like a problem with either your own code or Spacy; ERRANT doesn't use tok2vec or nlp.create_pipe.
ERRANT currently only supports spacy2, so also make sure you're not using spacy3 or spacy3 models.

Yvonne-LOK commented 2 years ago

Hi @chrisjbryant !

I changed the model to spacy2 version and the code executed successfully! Thank you so much for your help! =)