基于NLTK的预训练MaltParser模型

2024-09-30 01:31:54 发布

您现在位置:Python中文网/ 问答频道 /正文

有谁能告诉我如何使用一个预先训练的MaltParser模型吗(http://maltparser.org/mco/english_parser/engmalt.html)在nltk.parse.malt?唯一的选择似乎是从一个文件中进行培训(如果有人能为我指出一个好的、公开的培训文件的方向,那也太好了)。


Tags: 文件org模型httpparserenglishparsehtml
2条回答

NLTK旧版本中的MaltParser接口用于硬编码到模型的路径。在提交e9e443中修复了此问题。现在可以执行以下操作:

maltparser = MaltParser(mco="/path/to/your/model.mco")

在撰写本文时,easy\u install和pip仍然安装了NLTK的一个版本,该版本不包含此修复(2.0.1rc4)。如果您无法承受切换到最新版本的费用,可以使用以下方法:

^{pr2}$

预先训练的模型可以在MaltParser's official website上找到。在


关于使用预训练模型- 在nltk开发论坛上,这似乎一直是(而且似乎仍然是)一个开放的主题: https://github.com/nltk/nltk/issues/145

据我所知,你可以通过设置一些内部变量来实现:

"And while you can manually set the mco field on the object, that's not exposed in the API, and a user who hasn't dug into the code wouldn't know that."

但我找不到具体的地方来做这件事。在

关于获得一个经过预训练的模型-我建议您参考以下主题:

Does NLTK have a tool for dependency parsing?

相关问题 更多 >

    热门问题