首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NLP否定检测和停止字

NLP否定检测和停止字
EN

Stack Overflow用户
提问于 2019-09-15 07:31:08
回答 1查看 1K关注 0票数 0

我想通过否定检测来改进我的情感分析。我正在使用教授强调的词袋方法实现情感分析,这就是为什么我还没有使用CoreNLP的情感注释器。然而,我注意到它有一个问题。

给出一句话,“我对他们并不失望”,我希望,在最坏的情况下,从情感注释器和我自己的词袋实现中,都会有一个中立的情绪,或者是弱积极的情绪。情感注释器将这句话报告为否定。

代码语言:javascript
复制
I: PRP  Neutral
'm: VBP Neutral
not: RB Negative
disappointed: VBN   Negative
in: IN  Neutral
them: PRP   Neutral
.: .    Neutral
Negative
1

最后两行显示了句子的情感标签和数字情感得分。

如何提高情感注释器获得正确结果的机会,以及如何使用CoreNLP来检测所显示的否定、句子之间的否定以及多个句子之间对实体的引用(看起来就像coref和dcoref注释器)?

此外,潜在的有用之处是摆脱停用的单词。引理注释器似乎负责词干处理,但是哪个注释器会阻止单词?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-16 02:56:53

如果使用natlog注释器,则每个令牌都将标记一个NaturalLogicAnnotations.PolarityAnnotation。因此,否定的单词将具有down的极性。

代码语言:javascript
复制
package edu.stanford.nlp.examples;

import edu.stanford.nlp.ling.*;
import edu.stanford.nlp.naturalli.*;
import edu.stanford.nlp.pipeline.*;

import java.util.*;


public class NaturalLogicExample {

  public static String text = "I'm not disappointed in them.";

  public static void main(String[] args) {
    // set up pipeline properties
    Properties props = new Properties();
    // set the list of annotators to run
    props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,natlog");
    // build pipeline
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
    // create a document object
    CoreDocument document = new CoreDocument(text);
    // annnotate the document
    pipeline.annotate(document);
    for (CoreLabel token : document.tokens()) {
      System.out.println(String.format("%s\t%s", token.word(),
          token.get(NaturalLogicAnnotations.PolarityAnnotation.class)));
    }
  }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57940020

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档