【问题标题】:How to get the positive score only?如何只获得正分?
【发布时间】:2017-03-07 14:29:54
【问题描述】:

我是情绪分析的新手。我只想得到积极的分数,而不是像复合、否定、pos、中性。谁能帮我实现这个目标?

sid = SentimentIntensityAnalyzer()
ss = sid.polarity_scores(sentence) 

提前致谢。

【问题讨论】:

    标签: python-3.x nltk sentiment-analysis vader


    【解决方案1】:

    基于source code,该方法返回一个字典,其形状为:

    {"neg" : ..., "neu" : ..., "pos" : ..., "compound" : ...}
    

    所以你可以简单地使用:

    sid = SentimentIntensityAnalyzer()
    ss = sid.polarity_scores(sentence)['pos'] # the positive score

    这里['pos'] 获取与'pos' 键关联的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-13
      • 2012-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-02
      相关资源
      最近更新 更多