我使用 python 3.6,我想进行情绪分析,但我在 nltk.metrics 包中有错误?
I use python 3.6 and i want to make sentiment analysis but i have an error in nltk.metrics package?
我在这里写代码:
print ('pos precision:', nltk.metrics.precision(refsets['pos'],
testsets['pos']))
print ('pos recall:', nltk.metrics.recall(refsets['pos'],
testsets['pos']))
输出如下:
line 35, in evaluate_classifier
print ('pos precision:', nltk.metrics.precision(refsets['pos'],
testsets['pos']))
AttributeError: module 'nltk.translate.metrics' has no attribute
'precision'
我该如何解决这个错误?
没什么大不了的,只是没有调用正确的方法。
尝试:nltk.metrics.scores.precision(reference, test)
http://www.nltk.org/api/nltk.metrics.html
ctrl+f for "precision" 将带您进入文档
更正后的代码:
print('pos precision:', nltk.metrics.scores.precision(refsets['pos'],testsets['pos']))
print('pos recall:', nltk.metrics.scores.recall(refsets['pos'],testsets['pos']))
我在这里写代码:
print ('pos precision:', nltk.metrics.precision(refsets['pos'],
testsets['pos']))
print ('pos recall:', nltk.metrics.recall(refsets['pos'],
testsets['pos']))
输出如下:
line 35, in evaluate_classifier
print ('pos precision:', nltk.metrics.precision(refsets['pos'],
testsets['pos']))
AttributeError: module 'nltk.translate.metrics' has no attribute
'precision'
我该如何解决这个错误?
没什么大不了的,只是没有调用正确的方法。
尝试:nltk.metrics.scores.precision(reference, test)
http://www.nltk.org/api/nltk.metrics.html
ctrl+f for "precision" 将带您进入文档
更正后的代码:
print('pos precision:', nltk.metrics.scores.precision(refsets['pos'],testsets['pos']))
print('pos recall:', nltk.metrics.scores.recall(refsets['pos'],testsets['pos']))