NLTk POS Tagger错误

时间:2015-01-27 05:44:54

标签: python nltk pos-tagger

我安装了32位Python 3.4.1并且正在使用NLTK 3.已安装所有集合和模型。进入时

>>> text = nltk.word_tokenize("this is not working")
>>> text
['this', 'is', 'not', 'working']
>>> nltk.pos_tag(text)

或来自本地文件的令牌

尝试使用maxent_treebank_pos_tagger的pos_tag时出现以下错误

Traceback (most recent call last):
  File "<pyshell#72>", line 1, in <module>
    nltk.pos_tag(text)
  File "C:\Python34\lib\site-packages\nltk\tag\__init__.py", line 100, in pos_tag
    tagger = load(_POS_TAGGER)
  File "C:\Python34\lib\site-packages\nltk\data.py", line 779, in load
    resource_val = pickle.load(opened_resource)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcb in position 0: ordinal not in range(128)

帮助!

1 个答案:

答案 0 :(得分:0)

我将错误追溯到Windows 7系统和编码。

我跟着这个帖子的回答,https://stackoverflow.com/a/25590163/1956823 在Mac 10.10系统上尝试改变了编码,它运行了!