Vasyl Lyashkevych Vasyl Lyashkevych - 1 year ago 164
Python Question

NameError: name 'parser' is not defined in SpaCy

I have an example for working with NLP in spacy code:

from subject_object_extraction import findSVOs

# can still work even without punctuation
parse = parser("he and his brother shot me and my sister")

# very complex sample. Only some are correct. Some are missed.
parse = parser("Far out in the uncharted backwaters of the unfashionable end of the Western Spiral arm of the Galaxy lies a small unregarded yellow sun. ")

Before I installed all dictionaries for spacy:

$ sudo python -m all
$ python -m parser
$ python -m glove

but, as results, I have a mistake:

Traceback (most recent call last):
File "/home/vv/PythProj/", line 5, in <module>
nasa = parser.vocab['NASA']
NameError: name 'parser' is not defined

Please, Where is my mistake? Thank you

Answer Source

I think you are missing this:

# Set up spaCy
from spacy.en import English
parser = English()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download