【问题标题】:How to use quote annotator如何使用引用注释器
【发布时间】:2016-01-03 21:38:55
【问题描述】:

跑步

./corenlp.sh -annotators quote -outputFormat xml -file input.txt

关于修改后的输入文件

“斯坦福大学”位于加利福尼亚。这是一所伟大的大学,成立于 1891 年。

产生以下输出:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="CoreNLP-to-HTML.xsl" type="text/xsl"?>
<root>
  <document>
    <sentences/>
  </document>
</root>

也许我误解了这个注释器的预期用途,但我希望它能够标记句子中“。”之间的部分。

当我使用“常用”注释器 tokenize、ssplit、pos、lemma、ner 运行脚本时,它们都运行良好,但添加引号不会改变输出。我使用的是 stanford-corenlp-full-2015-12-09 版本。 如何使用引用注释器以及它的作用是什么?

【问题讨论】:

  • 更新:JSONOutputter 和 TextOutputter 在提交时启用了 JSON 输出和引号文本。 XML 输出仍未实现,因为当前的 xml 结构是基于句子的,并且引号可以跨越多个句子,这使得很好地实现并非易事。 github.com/stanfordnlp/CoreNLP/commit/…

标签: stanford-nlp


【解决方案1】:

如果您在 Java 代码中构建一个 StanfordCoreNLP 对象并使用引号注释器运行它,最终的 Annotation 对象将包含引号。

import java.io.*;
import java.util.*;
import edu.stanford.nlp.io.*;
import edu.stanford.nlp.ling.*;
import edu.stanford.nlp.pipeline.*;
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.trees.TreeCoreAnnotations.*;
import edu.stanford.nlp.semgraph.*;
import edu.stanford.nlp.ling.CoreAnnotations.*;
import edu.stanford.nlp.util.*;

public class PipelineExample {

    public static void main (String[] args) throws IOException {
        // build pipeline
        Properties props = new Properties();
        props.setProperty("annotators","tokenize, ssplit, quote");
        StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
        String text = "\"Stanford University\" is located in California. It is a great university, founded in 1891.";
        Annotation annotation = new Annotation(text);
        pipeline.annotate(annotation);
        System.out.println(annotation.get(CoreAnnotations.QuotationsAnnotation.class));
    }
}

目前没有任何输出器(json、xml、文本等)输出引号。我会记下我们应该将此添加到未来版本的输出中。

【讨论】:

  • 3.7.0 中似乎没有包含它,您能再做一个注释还是我们提交一个问题?
  • 有人可以提供有关如何在 CoreNLP 中集成此管道以及如何运行它以获得所需输出的信息吗?
  • 对我来说,它给出了错误:线程“main”java.lang.IllegalArgumentException 中的异常:注释器“quote”需要注释“CorefChainAnnotation”。这个注释器的通常要求是:tokenize,ssplit,pos,lemma,ner 我使用的是 3.9.1 版本
  • 如果您想要引用属性,您还需要运行 coref 以默认使用引用注释器。如果您想在没有 coref(并且没有归属)的情况下运行它,请使用属性 quote.attributeQuotes = false
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多