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

标签 machine-learning nlp crfsuite 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('文件路径', '文件名', 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'])

关于machine-learning - 如何在 python crfsuite 中使用 Conll 2003 语料库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45619892/

相关文章:

python - 随机PCA内存使用

python - 如何限制 Keras 中权重的格式

machine-learning - 在新的未标记的单一观察或数据集上使用经过测试的机器学习模型?

python - 在强化学习中标准化奖励以产生返回

string - 使用优先级队列高效实现BPE

python - 谷歌 Colab 中的 ScispaCy

python - 运行 CRFSuite 示例

ruby - 格式化相对日期

python - 如何使用词嵌入作为 CRF (sklearn-crfsuite) 模型训练的特征