我试图运行此代码:
import nltk
text = "Mrs. Hudson made a cup of tea. She is a wonderful woman."
sentences = nltk.tokenize.sent_tokenize(text)#breaks statement into
print sentences
#print tokens
tokens = [nltk.tokenize.word_tokenize(s) for s in sentences]#tokenizes sentences passes as list of lists
PosTokens = [nltk.pos_tag(e) for e in tokens]
当我运行它时出现错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'averaged_perceptron_tagger' is not defined
所以我运行下载器来获取标记器并根据这个问题我需要'maxtent_treebank_pos_tagger' nltk pos_tag usage
我得到以下内容:
nltk.download('maxtent_treebank_pos-tagger')
NameError: name 'averaged_perceptron_tagger' is not defined
>>> nltk.download('maxtent_treebank_pos-tagger')
[nltk_data] Error loading maxtent_treebank_pos-tagger: Package
[nltk_data] 'maxtent_treebank_pos-tagger' not found in index
False
所以我很难过所有的帮助!
答案 0 :(得分:0)
我想通了我输入的拼写错误
其nltk.download(maxent_treebank_pos_tagger)