IndexError: list index out of range
当调用tag_sents()
NLTK SennaTagger( http://www.nltk.org/_modules/nltk/tag/senna.html ) 的方法时。
给出一个句子列表作为tag_sents
方法的输入。
运行标记器需要一个 senna 可执行文件。可在此处找到 SENNA 工具包的安装指南。http://ronan.collobert.com/senna/
代码:
from nltk.tag import SennaTagger
SENNA_EXECUTABLE_DIR = '../../tools/senna'
pos_tagger = SennaTagger(SENNA_EXECUTABLE_DIR)
tagged = pos_tagger.tag_sents(["All the banks are closed", "Today is Sunday"])
输出:
Traceback (most recent call last):
File "<ipython-input-90-886051c3d91d>", line 1, in <module>
tagged = pos_tagger.tag_sents(["All the banks are closed", "Today is Sunday"])
File "F:\Programs\Anaconda3\lib\site-packages\nltk\tag\senna.py", line 55, in tag_sents
tagged_sents = super(SennaTagger, self).tag_sents(sentences)
File "F:\Programs\Anaconda3\lib\site-packages\nltk\classify\senna.py", line 161, in tag_sents
result[tag] = tags[map_[tag]].strip()
IndexError: list index out of rangeenter code here