NLTK POS tagger not working

你离开我真会死。 提交于 2019-12-29 07:47:07

问题


If I try this :

import nltk
text = nltk.word_tokenize("And now for something completely different")
nltk.pos_tag(text)

Output:

Traceback (most recent call last):
File "C:/Python27/pos.py", line 3, in <module>
nltk.pos_tag(text)
File "C:\Python27\lib\site-packages\nltk-2.0.4-py2.7.egg\nltk\tag\__init__.py" ipos_tag
tagger = load(_POS_TAGGER)
File "C:\Python27\lib\site-packages\nltk-2.0.4-py2.7.egg\nltk\data.py", line 605,in 
resource_val = pickle.load(_open(resource_url))
ImportError: No module named numpy.core.multiarray

回答1:


It seems that the saved word tokenizer requires numpy. You'll need to install it.




回答2:


Install numpy using the command:

sudo pip install -U numpy


来源:https://stackoverflow.com/questions/14506969/nltk-pos-tagger-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!