我试图将麦芽解析器与预制英语模型一起使用。但是,我不知道如何将英文句子的文本语料库转换为Malt Parser操作所必需的CoNLL格式。我在网站上找不到任何文档。我应该怎么做呢?
更新。我指的是这篇文章Create .conll file as output of Stanford Parser来创建一个.conll。但是,这是使用Stanford Parser。
答案 0 :(得分:8)
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 . . . _ _ _