【发布时间】:2015-10-19 21:49:29
【问题描述】:
我正在测试 NLTK 并尝试训练 punkttokenizer,我正在尝试获得 GWBush-2005 和 6 州工会演讲,并且我得到 Lazycorpusloader 不可调用。
代码:
import nltk
from nltk.corpus import state_union
from nltk.tokenize import PunktSentenceTokenizer
train_text = state_union("2005-GWBush.txt")
sample_text = state_union("2006-GWBush.txt")
custom_sent_tokenizer = PunktSentenceTokenizer(train_text)
tokenized = custom_sent_tokenizer.tokenize(sample_text)
def process_content():
try:
for i in tokenized:
words = nltk.word_tokenize(i)
tagged = nltk.pos_tag(words)
print tagged
except Exception as e:
print(str(e))
process_content()
错误:
Traceback (most recent call last):
File "C:\Users\smash_000\My Documents\Li-Clipse-Python\CodeTesting\blahblahblah\smallcodetesting.py", line 7, in <module>
train_text = state_union("2005-GWBush.txt")
TypeError: 'LazyCorpusLoader' object is not callable
【问题讨论】:
标签: python python-2.7 nltk typeerror