Bagofwords没有属性精度和

2024-03-29 14:38:13 发布

您现在位置:Python中文网/ 问答频道 /正文

import os


ENGLISH_OPINION_LEXICON_LOCATION = os.path.join('opinion-lexicon-English')

POS_WORDS_文件=os.path.join操作系统(英语观点词汇位置,积极的-文字.txt') NEG_WORDS_文件=os.path.join操作系统(英语观点词汇位置,否定-文字.txt')

pos_words=[({'amazing':True},'positive'),({'great':True},'positive')]

neg_words=[({'pathetic':True},'negative')]

^{pr2}$

在word()中打开单词'u.r'(位置:u) 位置_单词.追加({位置_单词.rstrip():真},'正')

^{3}$

我的错误如下: AttributeError:模块'nltk.translate.metrics'没有'scores'属性


Tags: 文件pathimporttxttrueenglishos单词
3条回答

我想您调用的精度函数不正确。 从docs看来您应该使用 nltk.metrics.scores.precision而不是{}。召回也是如此。在

你可以试试

from nltk import precision

并直接调用precision方法。它会起作用的!在

只需导入以下内容。 在

from nltk import precision

并直接调用精度方法,如下所示。在

^{pr2}$

它一定会奏效的!在

相关问题 更多 >