斯坦福OpenIE:如何输出依赖路径而不是纯文本模式?

时间:2016-01-18 00:41:36

标签: stanford-nlp

我正在查看Java源代码,并想知道是否容易修改系统,使得每个三元组的谓词部分是两个实体之间的依赖路径而不是表面形式。

由于自然逻辑模块在依赖树上运行,我想应该可以轻松调整这种需求。

我将edu.stanford.nlp.naturalli / OpenIE.java中的代码跟踪到:

// Get the extractions
boolean empty = true;
synchronized (OUTPUT) {
  for (CoreMap sentence : ann.get(CoreAnnotations.SentencesAnnotation.class)) {
    for (RelationTriple extraction : sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class)) {
      // Print the extractions
      OUTPUT.println(tripleToString(extraction, docid, sentence));
      empty = false;
    }
  }
}

请指出我执行以下步骤:

sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class)

谢谢!

1 个答案:

答案 0 :(得分:0)

每个关系三元组实际上存储了生成它的依赖关系结构。请查看asDependencyTree() function中的RelationTriple

注意,该树不一定是原始句子的子树 - 例如,可能是对象被移动以产生关系三元组。如果您在原始句子中查找依赖关系路径,则可以按其IndexAnnotation查找标记并从中计算依赖关系路径。

相关问题