简体   繁体   English

NLTK3 UnicodeDecode 错误

[英]NLTK3 UnicodeDecode Error

I'm not able to execute the below lines, the error is我无法执行以下几行,错误是

"UnicodeDecodeError: 'ascii' codec can't decode byte 0xcb in position 0: ordinal not in range(128)"

File "D:\\Py 64\\ anaconda\\lib\\site-packages\\nltk\\tag__init__.py", line 100, in pos_tag tagger = load(_POS_TAGGER)文件“D:\\Py 64\\anaconda\\lib\\site-packages\\nltk\\tag__init__.py”,第 100 行,在 pos_tag tagger = load(_POS_TAGGER)

File "D:\\Py 64\\ anaconda\\lib\\site-packages\\nltk\\data.py", line 779, in load resource_val = pickle.load(opened_resource, encoding='iso-8859-1')文件“D:\\Py 64\\anaconda\\lib\\site-packages\\nltk\\data.py”,第779行,在load resource_val = pickle.load(opened_resource, encoding='iso-8859-1')

My error is not just in data.py, but also in init .py.我的错误不仅出现在 data.py 中,还出现在init .py 中。

Note:- I have changed the code in data.py, line 779 as mentioned here注: -我在data.py改变了代码,行779所提到这里


text = word_tokenize("They refuse to permit us to obtain the refuse permit")

nltk.pos_tag(text)

I believe this problem is fixed using nltk 3.0.3 and the lastest maxent_treebank_pos_tagger model.我相信使用 nltk 3.0.3 和最新的maxent_treebank_pos_tagger模型可以解决此问题。

To install nltk, use要安装 nltk,请使用

pip install -U nltk

Make sure the pip you are calling is for Python3 .确保您调用的 pip 适用于 Python3

Once nltk is installed, open the Python3 interpreter, type:安装 nltk 后,打开 Python3 解释器,输入:

>>> import nltk
>>> nltk.download()

and use the GUI to install maxent_treebank_pos_tagger .并使用 GUI 安装maxent_treebank_pos_tagger It's located under the models tab:它位于models选项卡下:

models > maxent_treebank_pos_tagger

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM