首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TrueCaseAnnotator overwriteText选项

TrueCaseAnnotator overwriteText选项
EN

Stack Overflow用户
提问于 2019-09-13 03:56:56
回答 1查看 36关注 0票数 0

我试着写一个情绪预测器供评论。斯坦福大学的医生们说,写得不好的输入,比如大写,可以抛弃他们的工具,比如情绪检测。这就是我现在所处的洞。

我有以下几点:

代码语言:javascript
复制
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();
}

这一产出如下:

代码语言:javascript
复制
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

如果第一句中的“爱”是“爱”( truecase-d ),那么“爱”就是“非常积极的”。从任何角度来看,“爱”也应该是非常积极的。由于这会触发情绪检测,所以我想在情感检测之前将truecase-ing应用于管道中,docs 这里提到了用于TrueCaseAnnotatortruecase.overwriteText配置,但这似乎只适用于命令行。

问题:

  1. 如何将管道中的truecase-ing阶段配置为通过API以编程方式执行overwriteText步骤?
  2. 通常,如何在管道中配置注释器?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-13 14:10:47

基于打包的属性文件和文档,我在黑暗中拍摄了一张照片,然后做了:

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

这起作用了!这是在管道中配置注解器的方法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57917103

复制
相关文章

相似问题

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