我使用 python 3.6,我想进行情绪分析,但我在 nltk.metrics 包中有错误?

拉赞巴拉提亚

我在这里编写代码:

    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 表示“精度”将使您获得文档

更正的代码: print('pos precision:', nltk.metrics.scores.precision(refsets['pos'],testsets['pos'])) print('pos recall:', nltk.metrics.scores.recall(refsets['pos'],testsets['pos']))

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

我的查询中有错误

我在时区设置中有错误

导入错误,当我在NLTK Python中导入nltk.corpus.framenet时

我如何在python中使用nltk查找特定的bigram?

我在R.java中有错误?

我在 Verilog 上的定义中有错误 for

刽子手游戏在我的选择方法中有错误

python3 nltk,WordNetLemmatizer发生错误

Symfony 3 给了我 500 错误,没有错误

使用nltk“ python 3.7.4”进行错误的词法化

虽然没有错误,但我的 python pyw 文件没有打开

如何使用 case_when 而不是 if_else [我的代码中有错误?]

当我使用 ConcurrentMessageListenerContainer 时,如何跳过在 kafka 中有错误的味精?

我需要在没有 nltk 的情况下在 python 中执行 Stemming 操作。使用管道方法

我在joomla中有一个错误-请查询。我在这个查询中有错误

我现在没有,为什么我在这个 sql 请求中有错误

我不能使用wiredep注入bower软件包并且没有错误?

我的代码中有错误,当前错误是 TypeError: 'NoneType' object is not subscriptable

为什么我使用python3遇到分段错误?

当我有单逗号和|时,SQL语法中有错误。

为什么我收到这个错误?似乎我在 s1.grade_level 中有错误,但我不知道为什么

我正在使用 python3 并且我想翻译一些文本,所以我使用了“googletrans”包,但出现了一些错误

使用python3和nltk从模块调用函数的问题

我想使用 Google Maps API,但我的 React.JS 代码中有 3D 建筑物

我在我的get方法中有错误,它向我显示404错误.net核心和角度

我如何在python / nltk中使用完整的Penn树库数据集

我可以在Python中使用NLTK从Spacy依赖关系树中找到主题吗?

Python无法在我的脚本中“导入nltk”,但可以在解释器中使用

如果我们在CloudFormation中有错误条件和Ref会发生什么?