TrueCaseAnnotator overwriteText 选项

TrueCaseAnnotator overwriteText option

我正在尝试为评论编写情绪预测器。斯坦福文档说写得不好的输入,例如资本化,可以摆脱他们的工具,比如情绪检测。这就是我现在所处的困境。

我有以下内容:

Properties prop = new Properties();
prop.setProperty( "annotators", "tokenize, ssplit, truecase, pos, parse, sentiment" );
StanfordCoreNLP pipeline = new StanfordCoreNLP( prop );
Annotation doc = new Annotation( "I LOVE Target products. I love myself, too." );
List<CoreMap> sentences = doc.get(CoreAnnotations.SentencesAnnotation.class);
for(CoreMap sentence : sentences)
{
  for(CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)
  {
    System.out.println(token + ": " + token.get(SentimentCoreAnnotations.SentimentClass.class));
  }
  System.out.println();
}

这输出:

I-1: Neutral
LOVE-2: Neutral
Target-3: Neutral
products-4: Neutral
.-5: Neutral

I-1: Neutral
love-2: Very positive
myself-3: Neutral
,-4: Neutral
too-5: Neutral
.-6: Neutral

如果第一句中的"LOVE"是truecase-d为"love",那么情感出来就是"Very positive"。从任何角度来说,"LOVE"应该也是非常积极的。由于这会影响情绪检测,我想在情绪检测之前在管道中应用 truecase-ing,文档 here 提到了 TrueCaseAnnotatortruecase.overwriteText 配置,但那似乎仅适用于命令行。

问题:

  1. 如何配置管道中的 truecase-ing 阶段以通过 API?
  2. 以编程方式执行 overwriteText 步骤
  3. 一般情况下,如何在管道中配置注释器?

根据打包的属性文件和文档,我在黑暗中拍摄并做了:

prop.setProperty("truecase.overwriteText", "true");

成功了!这是在管道中配置注释器的方法。