如何解释RNNCoreAnnotations.getPredictedClass值?

时间:2015-08-27 11:45:16

标签: nlp stanford-nlp sentiment-analysis

我使用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的'情绪'模块,它会为“Cats aare stupid。”返回-2,而4为“Cats太棒了!”。

{ 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

1 个答案:

答案 0 :(得分:2)

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

总结:

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