这是第一次玩python,我正在尝试复制并运行一些在线可用的代码,以了解它们是如何工作的,但其中一些不起作用。这是我在尝试使用NLTK复制在python中执行词性的程序时遇到的问题的示例。
import nltk
import re
import time
exampleArray = ['The incredibly intimidating NLP scares people who are sissies.']
def processLanguage():
try:
for item in exampleArray:
tokenized = nltk.word_tokenized(item)
tagged = nltk.pos_tag(tokenized)
except Exception, e:
print str(e)
processLanguage()
问题是当我运行此代码时,我收到此消息:
'module' object has no attribute 'word_tokenize'
'module' object has no attribute 'word_tokenized'
你能告诉我如何解决这个问题。