【问题标题】:How to interprete RNNCoreAnnotations.getPredictedClass value?如何解释 RNNCoreAnnotations.getPredictedClass 值?
【发布时间】:2015-08-27 11:45:15
【问题描述】:

我使用 CoreNLP 3.3.0 版来测试情绪分析。代码如下所示:-

val pipeline = new StanfordCoreNLP("build.properties") // build.properties contain one line - "annotators = tokenize, ssplit, parse, sentiment"
...
pipeline.map { p =>
val annotation =  p.process(sentence)
annotation.get(classOf[SentencesAnnotation]).foreach { sen =>
    val tree = sen.get(classOf[AnnotatedTree])
    val sentiment = RNNCoreAnnotations.getPredictedClass(tree)        
    ...
}

我在传递句子时发现

  • “猫很笨”,值为2;
  • “猫太棒了!” 0;
  • “风很大。” 2.

我很困惑,因为它与其他程序不同,例如节点 js 的“情感”模块,它会返回 -2 表示“Cats aare蠢”,而 4 表示“Cats are amazing!”。

{ score: -2,
  comparative: -0.6666666666666666,
  tokens: [ 'cats', 'are', 'stupid' ],
  words: [ 'stupid' ],
  positive: [],
  negative: [ 'stupid' ] }
{ score: 4,
  comparative: 1,
  tokens: [ 'cats', 'are', 'totally', 'amazing' ],
  words: [ 'amazing' ],
  positive: [ 'amazing' ],
  negative: [] }

查看java文档,它只解释了

以 int 形式返回预测的类。如果没有为节点定义,则返回-1

http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/neural/rnn/RNNCoreAnnotations.html#getPredictedClass-edu.stanford.nlp.trees.Tree-

我想知道如何解释这样的价值。还是我调用了错误的函数来获取情绪分数?

谢谢

不使用 3.4.0 或 3.5.2 的原因来自 CoreNLP 抛出以下异常

edu.stanford.nlp.io.RuntimeIOException: java.lang.ClassNotFoundException: edu.stanford.nlp.rnn.SimpleTensor

而且似乎新版本需要edu.stanford.nlp.neural 包中的SimpleTensor 而不是rnn

【问题讨论】:

    标签: nlp stanford-nlp sentiment-analysis


    【解决方案1】:

    查看类似问题的答案:https://stackoverflow.com/a/32447855

    总结:

    0: "Very Negative"
    1: "Negative" 
    2: "Neutral" 
    3: "Positive" 
    4: "Very Positive"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-15
      • 2017-10-26
      • 1970-01-01
      • 2015-03-23
      • 2018-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多