如何使用引号注释器

时间:2016-01-03 21:38:56

标签: stanford-nlp

运行

  

./ 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发布。 我如何使用引用注释器以及它的意图?

1 个答案:

答案 0 :(得分:4)

如果您在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,text等等)输出引号。我将记下我们应该将其添加到输出中以供将来版本使用。

相关问题