Stanford nlp 斯坦福大学corenlp中的自然语言逻辑

Stanford nlp 斯坦福大学corenlp中的自然语言逻辑,stanford-nlp,Stanford Nlp,如何使用斯坦福大学CoreNLP的自然逻辑组件 我使用的是CoreNLP 3.9.1,我在命令行中将natlog作为注释器输入,但我似乎在输出中看不到任何natlog结果,即,OperatorAnnotation和PolarityAnnotation,根据。这和outputFormat有什么关系吗?我尝试过xml和json,但都没有自然逻辑的输出。不过,其他东西(标记化、dep解析)也在其中 这是我的命令: ./corenlp.sh -annotators tokenize,ssplit,pos

如何使用斯坦福大学CoreNLP的自然逻辑组件

我使用的是CoreNLP 3.9.1,我在命令行中将natlog作为注释器输入,但我似乎在输出中看不到任何natlog结果,即,
OperatorAnnotation
PolarityAnnotation
,根据。这和outputFormat有什么关系吗?我尝试过xml和json,但都没有自然逻辑的输出。不过,其他东西(标记化、dep解析)也在其中

这是我的命令:

./corenlp.sh -annotators tokenize,ssplit,pos,lemma,depparse,natlog -file natlog.test -outputFormat xml

提前感谢。

我认为任何输出选项都不会显示natlog内容。如果您有一个Java系统,并且在Java代码中使用注释本身,那么这种设计就更为合理。您应该可以通过查看每个令牌的CoreLabel来查看它们。

此代码片段适用于我:

导入edu.stanford.nlp.ling.corelab;
导入edu.stanford.nlp.pipeline.StanfordCoreNLP;
导入edu.stanford.nlp.util.CoreMap;
导入edu.stanford.nlp.ling.CoreAnnotations.NamedEntityTagAnnotation;
导入edu.stanford.nlp.ling.CoreAnnotations.PartOfSpeechAnnotation;
导入edu.stanford.nlp.ling.CoreAnnotations.SentencesAnotation;
导入edu.stanford.nlp.ling.CoreAnnotations.TextAnnotation;
导入edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation;
导入edu.stanford.nlp.pipeline.Annotation;
//这是极性注释!
导入edu.stanford.nlp.naturalli.NaturalLogicAnnotations.PolarityDirectionAnnotation;
//不是下面的那个!
//导入edu.stanford.nlp.ling.CoreAnnotations.PolarityAnnotation;
导入edu.stanford.nlp.util.PropertiesUtils;
导入java.io.*;
导入java.util.*;
公开课考试{
公共静态void main(字符串[]args)引发FileNotFoundException、UnsupportedEncodingException{
//代码来源:https://stanfordnlp.github.io/CoreNLP/api.html#generating-注释
StanfordCoreNLP管道=新的StanfordCoreNLP(
PropertiesUtils.asProperties(
//**在此处添加natlog**
“注释器”、“标记化、ssplit、pos、引理、解析、解析、natlog”,
“ssplit.eolonly”、“true”,
“tokenize.language”、“en”);
//读取文本变量中的一些文本
String text=“每只狗都能看到一些猫”;
注释文档=新注释(文本);
//在此文本上运行所有注释器
管道注释(文件);
//这些是本文件中的所有句子
//CoreMap本质上是一个使用类对象作为键并具有自定义类型值的映射
列出句子=document.get(SentencesAnnotation.class);
for(CoreMap句子:句子){
//遍历当前句子中的单词
//CoreLabel是一个CoreMap,具有额外的令牌特定方法
for(CoreLabel标记:句子.get(TokensAnnotation.class)){
//这是令牌的文本
String word=token.get(TextAnnotation.class);
//这是令牌的POS标记
String pos=token.get(speechannotation.class的一部分);
//这是令牌的NER标签
字符串ne=token.get(NamedEntityTagAnnotation.class);
//这是令牌的极性标签
字符串pol=token.get(PolarityDirectionAnnotation.class);
系统输出打印(word+“[”+pol+“]”);
}
System.out.println();
}
}
}
输出将是:
每只[向上]的狗[向下]都能看到[向上]一些[向上]的猫[向上]

我的测试句子看起来像:“没有学生走路”。所以我希望输出中有向下的极性。非常感谢!我将在java中试用它。