【问题标题】:How to convert text file to CoNLL format for malt parser?如何将文本文件转换为麦芽解析器的 CoNLL 格式?
【发布时间】:2015-01-13 18:38:25
【问题描述】:

我正在尝试将 malt 解析器与预制的英文模型一起使用。但是,我不知道如何将英语句子的文本语料库转换为 Malt Parser 运行所需的 CoNLL 格式。我在网站上找不到任何文档。我该怎么办?

更新。我指的是这个帖子Create .conll file as output of Stanford Parser 来创建一个.conll。但是,这是使用斯坦福解析器。

【问题讨论】:

  • 这是原始文本语料库还是树库?您需要有一个带有依赖注释的语料库(依赖树库或选区树库,可以转换为依赖树库)。
  • 这只是一个原始文本语料库,我上面链接的帖子有一个通过斯坦福解析器检索选区树库的过程,但这是一个 .tree 文件。我相信 Malt Parser 只接受 .conll 文件?

标签: parsing nlp stanford-nlp pos-tagger


【解决方案1】:

CoreNLP 输出有一个 CoNLL 格式化选项,但不幸的是它与 MaltParser 期望的不匹配。 (令人困惑的是,对于不同的比赛年份,有几种不同的常见 CoNLL 数据格式..)

如果您使用选项 -outputFormat conll 从命令行运行 CoreNLP,您将获得以下 TSV 格式的输出(答案末尾的示例输出):

INDEX    WORD    LEMMA    POS    NER    DEPHEAD    DEPREL

MaltParser 需要的格式有点不同,但您可以自定义数据输入/输出格式。尝试将此内容放入maltparser/appdata/dataformat/myconll.xml

<?xml version="1.0" encoding="UTF-8"?>
<dataformat name="myconll" reader="tab" writer="tab">
    <column name="ID" category="INPUT" type="INTEGER"/>
    <column name="FORM" category="INPUT" type="STRING"/>
    <column name="LEMMA" category="INPUT" type="STRING"/>
    <column name="POSTAG" category="INPUT" type="STRING"/>
    <column name="NER" category="IGNORE" type="STRING"/>
    <column name="HEAD" category="HEAD" type="INTEGER"/>
    <column name="DEPREL" category="DEPENDENCY_EDGE_LABEL" type="STRING"/>
</dataformat>

然后添加到您的 MaltParser 配置文件(在 maltparser/examples/optionexample.xml 中找到示例配置):

<?xml version="1.0" encoding="UTF-8"?>
<experiment>
    <optioncontainer>
...
        <optiongroup groupname="input">
            <option name="format" value="myconll"/>
        </optiongroup>
    </optioncontainer>
...
</experiment>

那么您应该能够将 CoreNLP CoNLL 输出作为训练数据提供给 MaltParser。

未经测试,但如果 MaltParser 文档是诚实的,这应该可以工作。资料来源:


CoreNLP CoNLL 输出示例(我只使用了注释器tokenize,ssplit,pos):

$ echo "This is a test." | java edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos -outputFormat conll 2>/dev/null

1   This    this    DT  _   _   _
2   is  be  VBZ _   _   _
3   a   a   DT  _   _   _
4   test    test    NN  _   _   _
5   .   .   .   _   _   _

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-02
    • 2018-07-10
    • 2021-12-08
    • 2022-01-11
    • 2012-02-29
    相关资源
    最近更新 更多