【发布时间】: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
我想知道如何解释这样的价值。还是我调用了错误的函数来获取情绪分数?
谢谢
不使用 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