【问题标题】:Using openIE to extract negation使用openIE提取否定
【发布时间】:2016-10-10 10:24:57
【问题描述】:

我正在尝试使用 Stanford CoreNLP 测试 OpenIE http://nlp.stanford.edu/software/openie.html

我正在使用基于http://stanfordnlp.github.io/CoreNLP/openie.html 上提供的演示之一的以下代码

public static void main(String[] args) throws Exception {
    // Create the Stanford CoreNLP pipeline
Properties props = new Properties();

props.setProperty("annotators", "tokenize,ssplit,pos,lemma,depparse,natlog,openie");
props.setProperty("openie.triple.strict", "false");

StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// Annotate an example document.
//File inputFile = new File("src/test/resources/0.txt");
//String text = Files.toString(inputFile, Charset.forName("UTF-8"));
String text = "Cats do not drink milk.";
Annotation doc = new Annotation(text);
pipeline.annotate(doc);

// Loop over sentences in the document
for (CoreMap sentence : doc.get(CoreAnnotations.SentencesAnnotation.class)) {
  // Get the OpenIE triples for the sentence
  Collection<RelationTriple> triples = sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class);
  // Print the triples
  for (RelationTriple triple : triples) {
    System.out.println(triple.confidence + "|\t" +
        triple.subjectLemmaGloss() + "|\t" +
        triple.relationLemmaGloss() + "|\t" +
        triple.objectLemmaGloss());
  }
}

}

这违反直觉导致三元组

1.0|    cat|    drink|  milk

被提取,这与我使用输入文本“猫喝牛奶”得到的结果相同。如果我将“openie.triple.strict”设置为“true”,则根本不会提取三元组。有没有办法像猫一样提取三元组?不喝酒 |牛奶?

【问题讨论】:

  • 我收到 Java 堆大小错误的确切代码!你有过这样的问题吗?

标签: stanford-nlp information-extraction


【解决方案1】:

我认为您想将“openie.triple.strict”设置为 true 以确保符合逻辑的三元组。 OpenIE 不提取负面关系,它只是为了找到正面关系而设计的。

因此,当“openie.triple.strict”设置为 true(即未提取关系)时,您将获得正确的行为。请注意,为“猫喝牛奶”提取了一个关系。当 "openie.triple.strict" 设置为 true 时。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    • 1970-01-01
    • 2016-05-10
    • 1970-01-01
    相关资源
    最近更新 更多