繁体   English   中英

如何在python crfsuite中使用Conll 2003语料库

[英]How do I use Conll 2003 corpus in python crfsuite

我已经下载了Conll 2003语料库(“ eng.train”)。 我想使用它通过python crfsuite训练来提取实体。 但是我不知道如何加载该文件进行培训。

我找到了这个例子,但它不是英语的。

train_sents = list(nltk.corpus.conll2002.iob_sents('esp.train'))
test_sents = list(nltk.corpus.conll2002.iob_sents('esp.testb'))

同样,将来我想训练POS或位置以外的新实体。 我该如何添加这些。

还请提出如何处理多个单词的建议。

您可以使用ConllCorpusReader

这里是一个一般的实现ConllCorpusReader('file path', 'file name', columntypes=['','',''])

您可以在此处使用的列类型列表'WORDS', 'POS', 'TREE', 'CHUNK', 'NE', 'SRL', 'IGNORE'

范例

from nltk.corpus.reader import ConllCorpusReader

train = ConllCorpusReader('CoNLL-2003', 'eng.train', ['words', 'pos', 'ignore', 'chunk'])
test = ConllCorpusReader('CoNLL-2003', 'eng.testa', ['words', 'pos', 'ignore', 'chunk'])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM