【问题标题】:stanford-nlp How to predict document levelstanford-nlp 如何预测文档级别
【发布时间】: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


    【解决方案1】:

    据我所知,Stanford NLP 不提供句子级别以上的情感分析。一种解决方案是计算文本中所有句子的某种平均情绪值,但显然这只会让你对整体情绪有一个粗略的了解。

    【讨论】:

    • 我想我们会想出自己的算法来确定它。感谢您的帮助
    • @VinojMathew,你提出算法了吗?
    【解决方案2】:

    Yvespeirsman 走在正确的轨道上。您可以计算整个文档中某个术语的平均值。如果您将整个文档分解成句子,然后计算每个句子的情绪并计算平均值,这应该可以让您很好地了解整个研究文档中关于该术语的情绪

    我们用可见的源代码实现了他的实现:https://algorithmia.com/algorithms/nlp/SentimentByTerm

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-20
      • 1970-01-01
      • 2015-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多