stanford-nlp 如何预测文档级别
stanford-nlp How to predict document level
我使用的是 stanford-corenlp-3.4.1 版本。我有问题如果我们给句子有多个句子,我该如何计算预测。
例如:
字符串文本 = "IT was very fantastic experience. it was a pathetice experience";
我得到
的预测
这是非常棒的体验:积极。
这是一次悲惨的经历:消极。
我得到了基于每个句子的预测level.how我得到它的文档级别吗?
根据阅读全部文本,我需要得到它的正面或负面。
示例代码如下:
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 不提供句子级别以上的情感分析。一种解决方案是计算文本中所有句子的某种平均情绪值,但显然这只会让您对整体情绪有一个粗略的了解。
Yvespeirsman 走在正确的轨道上。您可以计算整个文档中某个术语的平均值。如果您将整个文档分解成句子,然后计算每个句子的情绪并计算平均值,这应该可以让您很好地了解整个研究文档中关于该术语的情绪
我们实现了他的源代码可见:https://algorithmia.com/algorithms/nlp/SentimentByTerm
我使用的是 stanford-corenlp-3.4.1 版本。我有问题如果我们给句子有多个句子,我该如何计算预测。
例如: 字符串文本 = "IT was very fantastic experience. it was a pathetice experience";
我得到
的预测这是非常棒的体验:积极。
这是一次悲惨的经历:消极。
我得到了基于每个句子的预测level.how我得到它的文档级别吗?
根据阅读全部文本,我需要得到它的正面或负面。
示例代码如下:
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 不提供句子级别以上的情感分析。一种解决方案是计算文本中所有句子的某种平均情绪值,但显然这只会让您对整体情绪有一个粗略的了解。
Yvespeirsman 走在正确的轨道上。您可以计算整个文档中某个术语的平均值。如果您将整个文档分解成句子,然后计算每个句子的情绪并计算平均值,这应该可以让您很好地了解整个研究文档中关于该术语的情绪
我们实现了他的源代码可见:https://algorithmia.com/algorithms/nlp/SentimentByTerm