【发布时间】:2015-04-10 00:25:52
【问题描述】:
我使用的是 stanford-corenlp-3.4.1 版本。我有一个问题,如果我们给出的句子有多个句子,我该如何计算预测。
例如: String text = "IT 是非常棒的体验。这是一种可悲的体验";
我得到了
的预测这是非常棒的体验:积极的。
这是一次悲惨的经历:负面的。
我正在根据每个句子级别获得预测。我如何获得它的文档级别。
基于阅读全部文本,我需要得到正面或负面的结果。
这里是示例代码:
Properties props = new Properties();
props.setProperty("annotators","tokenize, ssplit, pos, lemma, parse, sentiment");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation annotation = new Annotation("IT was very fantastic experience. it was a pathetice experience");
pipeline.annotate(annotation);
List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
String sentiment = sentence.get(SentimentCoreAnnotations.ClassName.class);
System.out.println(sentiment + "\t" + sentence);
}
结果:
非常积极:这是非常棒的体验。 否定这是一种可悲的经历
谢谢
【问题讨论】:
标签: stanford-nlp sentiment-analysis