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 . . . _ _ _