【问题标题】:how to make customize NER model using nlp如何使用 nlp 制作自定义 NER 模型
【发布时间】:2016-06-04 18:57:34
【问题描述】:
嗨,我知道 stanfordNERenglish.muc.7class.dissim.crf.ser.gz 有助于对 7 个类别进行分类:位置、人员、组织、金钱、百分比、日期、时间,但我想将文本分类为 7 个类别,但说人的全名,金钱,日期,时间,地点,学位等……请告诉我如何自定义模型nlp库斯坦福nlp/门/打开nlp
【问题讨论】:
标签:
nlp
stanford-nlp
opennlp
gate
【解决方案1】:
好吧,如果您使用 opennlp(如 documentation 中所述),请创建您的训练数据:
<START:person> Pierre Vinken <END> , 61 years old , will join the board as a nonexecutive director Nov. 29 .
Mr . <START:person> Vinken <END> is chairman of Elsevier N.V. , the Dutch publishing group .
这些标签是您为要查找的所有不同实体添加的标签。
并使用文档中提供的训练 API 或 CLI 并制作模型。
另外,如果你的训练集有大约 15000 行,那么你可以期待好的结果!
【解决方案2】:
在 OpenNLP 中,您可以使用以下步骤创建自定义 NER 模型。
首先,您需要以给定格式<START:entity-name> .....<END> 训练数据。假设您要创建医学 NER 模型。所以它会是这样的:
例子:
<START:medicine> Augmentin-Duo <END> is a penicillin antibiotic that contains two medicines -
<START:medicine> amoxicillin trihydrate <END> and <START:medicine> potassium clavulanate <END>. They work together to kill certain types of bacteria and are used to treat certain types of bacterial infections
训练数据至少要有 15000 句才能得到更好的结果。
使用 TokenNameFinderModel 类,使用所需的模型名称、数据文件路径调用。
您可以使用命令行创建一个这样的:
$opennlp TokenNameFinderTrainer -model en-ner-drugs.bin -lang en -data drugsDetails.txt -encoding UTF-8
要使用 java 做同样的事情,你可以参考这篇文章:Writing a custom NameFinder model in OpenNLP。