建立自定义命名实体识别(NLP)模型

问题描述 投票:3回答:1

我正在尝试使用R中的OpenNLP从文本中提取人的名字。但是,每当我使用印度名字时,该模型都无法检测到名字。因此,我了解到我需要构建自定义模型。我已经使用Java构建了自己的en-ner-customperson.bin

我不了解如何在我的R代码中使用此自定义模型?

我正在使用以下代码:

require("NLP")
## Some text.
s <- paste(c("Hardik, 61 years old, will join the board as a ",
             "nonexecutive director Nov. 29.\n",
             "Mr. Vinken is chairman of Elsevier N.V., ",
             "the Dutch publishing group."),
           collapse = "")
s <- as.String(s)
## Need sentence and word token annotations.
sent_token_annotator <- Maxent_Sent_Token_Annotator()
word_token_annotator <- Maxent_Word_Token_Annotator()
a2 <- annotate(s, list(sent_token_annotator, word_token_annotator))
## Entity recognition for persons.
entity_annotator <- Maxent_Entity_Annotator()
entity_annotator
annotate(s, entity_annotator, a2)
## Directly:
entity_annotator(s, a2)
## And slice ...
s[entity_annotator(s, a2)]
## Variant with sentence probabilities as features.
annotate(s, Maxent_Entity_Annotator(probs = TRUE), a2)

是否有任何文档可用于在R中构建自定义模型?如何建立自定义模型并与R

一起使用
r nlp opennlp text-analysis
1个回答
0
投票

尝试将自定义模型en-ner-customperson.bin放在您的工作目录中。然后,按如下所示指定modelMaxent_Entity_Annotator参数:

entity_annotator <- Maxent_Entity_Annotator(model = "en-ner-customperson.bin")
© www.soinside.com 2019 - 2024. All rights reserved.