NLTK库中使用不同的约定来标记单词。在NLTK中,如果希望给单词标注词性,则需要已经安装了averaged_perceptron_tagger_eng模块,但是几乎索引NLTK下载包中都没有该模块。如果没有该模块,运行代码时,例如下面代码:
import nltk
# 原始英文文本
sentence = 'Python is a programming language that lets you work qulckly and integrate systems more effectively.'
words = nltk.word_tokenize(sentence)
wordscixing = nltk.pos_tag(words) # 为列表中的每个单词标注词性
print(wordscixing)
则会提示:
>>> import nltk
>>> nltk.download('averaged_perceptron_tagger_eng')
只有通过梯子才能下载
下载后, 解压缩,放在硬盘的C:\nltk_data\taggers\averaged_perceptron_tagger_eng文件夹下。