我试着写一个情绪预测器供评论。斯坦福大学的医生们说,写得不好的输入,比如大写,可以抛弃他们的工具,比如情绪检测。这就是我现在所处的洞。
我有以下几点:
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如果第一句中的“爱”是“爱”( truecase-d ),那么“爱”就是“非常积极的”。从任何角度来看,“爱”也应该是非常积极的。由于这会触发情绪检测,所以我想在情感检测之前将truecase-ing应用于管道中,docs 这里提到了用于TrueCaseAnnotator的truecase.overwriteText配置,但这似乎只适用于命令行。
问题:
truecase-ing阶段配置为通过API以编程方式执行overwriteText步骤?发布于 2019-09-13 14:10:47
基于打包的属性文件和文档,我在黑暗中拍摄了一张照片,然后做了:
prop.setProperty("truecase.overwriteText", "true");
这起作用了!这是在管道中配置注解器的方法。
https://stackoverflow.com/questions/57917103
复制相似问题