【问题标题】:Stanford CoreNLP: output in CONLL format from Java斯坦福 CoreNLP:以 CONLL 格式从 Java 输出
【发布时间】:2016-09-19 19:27:14
【问题描述】:

我想用 Stanford CoreNLP 解析一些德语文本并获得一个 CONLL 输出,以便我可以将后者传递给 CorZu 进行共指解析。

我该如何以编程方式做到这一点?

这是我目前的代码(仅输出依赖树):

Annotation germanAnnotation = new Annotation("Gestern habe ich eine blonde Frau getroffen");
Properties germanProperties = StringUtils.argsToProperties("-props", "StanfordCoreNLP-german.properties");
StanfordCoreNLP pipeline = new StanfordCoreNLP(germanProperties);
pipeline.annotate(germanAnnotation);

StringBuilder trees = new StringBuilder("");
for (CoreMap sentence : germanAnnotation.get(CoreAnnotations.SentencesAnnotation.class)) {
     Tree sentenceTree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);
     trees.append(sentenceTree).append("\n");
}

【问题讨论】:

    标签: format dependencies stanford-nlp


    【解决方案1】:

    通过以下代码,我设法将解析输出保存为 CONLL 格式。

    OutputStream outputStream = new FileOutputStream(new File("./target/", OUTPUT_FILE_NAME));
    CoNLLOutputter.conllPrint(germanAnnotation, outputStream, pipeline);
    

    但是,所有单词的 HEAD 字段都是 0。我不确定解析中是否存在问题或仅在 CONLLOutputter 中存在问题。老实说,CoreNLP 让我非常恼火,无法进一步调查。

    我决定并建议改用 ParZu。 ParZuCorZu 可以无缝地协同工作 - 他们确实做到了。 就我而言,我有一个已经标记化和 POS 标记的文本。这使事情变得更容易,因为您将不需要

    • 使用 STTS 标记集的 POS 标记器
    • 形态分析工具

    安装 ParZu 和 CorZu 后,您只需运行 corzu.sh(包含在 CorZu 下载文件夹中)。如果您的文本被标记和 POS 标记,您可以相应地编辑脚本:

    parzu_cmd="/YourPath/ParZu/parzu -i tagged"
    

    最后一点:确保将您的标记文本转换为以下格式,空行表示句子边界:word [tab] tag [newline]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-05
      相关资源
      最近更新 更多