本文介绍了什么是 NLTK POS 标记器要求我下载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始使用词性标注器,我面临着很多问题.
我开始使用以下 POS 标记:
import nltktext=nltk.word_tokenize("我们要出去了.只有你和我.")
当我想打印 'text'
时,会发生以下情况:
print nltk.pos_tag(text)回溯(最近一次调用最后一次):文件<stdin>",第 1 行,在 <module> 中文件F:Python26libsite-packages
ltk ag\__init__.py",第 63 行,在 pos_tag 中标记器 = nltk.data.load(_POS_TAGGER)文件F:Python26libsite-packages
ltkdata.py",第 594 行,加载中resource_val = pickle.load(_open(resource_url))文件F:Python26libsite-packages
ltkdata.py",第 673 行,在 _open返回查找(路径).打开()文件F:Python26libsite-packages
ltkdata.py",第 455 行,在 find引发查找错误(resource_not_found)`查找错误:资源 'taggers/maxent_treebank_pos_tagger/english.pickle' 不是成立.请使用NLTK下载器获取资源:>>>nltk.download().搜索于:- 'C:\Documents and Settings\Administrator/nltk_data'- 'C:\nltk_data'- 'D:\nltk_data'- 'E:\nltk_data'- 'F:\Python26\nltk_data'- 'F:\Python26\lib\nltk_data'- 'C:\Documents and Settings\Administrator\Application Data\nltk_data'
我使用了 nltk.download()
但它没有用.
解决方案
来自NLTK
v3.2以上的版本,请使用:
对于使用旧 MaxEnt 模型的 NLTK
版本,即 v3.1 及以下,请使用:
有关默认pos_tag
更改的更多详细信息,请参阅https://github.com/nltk/nltk/pull/1143
I just started using a part-of-speech tagger, and I am facing many problems.
I started POS tagging with the following:
import nltk
text=nltk.word_tokenize("We are going out.Just you and me.")
When I want to print 'text'
, the following happens:
print nltk.pos_tag(text)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "F:Python26libsite-packages
ltk ag\__init__.py", line 63, in pos_tag
tagger = nltk.data.load(_POS_TAGGER)
File "F:Python26libsite-packages
ltkdata.py", line 594, in load
resource_val = pickle.load(_open(resource_url))
File "F:Python26libsite-packages
ltkdata.py", line 673, in _open
return find(path).open()
File "F:Python26libsite-packages
ltkdata.py", line 455, in find
raise LookupError(resource_not_found)`
LookupError:
Resource 'taggers/maxent_treebank_pos_tagger/english.pickle' not
found. Please use the NLTK Downloader to obtain the resource:
>>> nltk.download().
Searched in:
- 'C:\Documents and Settings\Administrator/nltk_data'
- 'C:\nltk_data'
- 'D:\nltk_data'
- 'E:\nltk_data'
- 'F:\Python26\nltk_data'
- 'F:\Python26\lib\nltk_data'
- 'C:\Documents and Settings\Administrator\Application Data\nltk_data'
I used nltk.download()
but it did not work.
解决方案
From NLTK
versions higher than v3.2, please use:
>>> import nltk
>>> nltk.__version__
'3.2.1'
>>> nltk.download('averaged_perceptron_tagger')
[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data] /home/alvas/nltk_data...
[nltk_data] Package averaged_perceptron_tagger is already up-to-date!
True
For NLTK
versions using the old MaxEnt model, i.e. v3.1 and below, please use:
>>> import nltk
>>> nltk.download('maxent_treebank_pos_tagger')
[nltk_data] Downloading package maxent_treebank_pos_tagger to
[nltk_data] /home/alvas/nltk_data...
[nltk_data] Package maxent_treebank_pos_tagger is already up-to-date!
True
For more details on the change in the default pos_tag
, please see https://github.com/nltk/nltk/pull/1143
这篇关于什么是 NLTK POS 标记器要求我下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!