R 构建自定义命名实体识别(NLP)模型
我试图使用R中的OpenNLP从文本中提取人名。但是,每当我使用印度人名时,该模型都无法检测人名。因此,我明白我需要构建自定义模型。我已经使用Java构建了自己的R 构建自定义命名实体识别(NLP)模型,r,nlp,opennlp,text-analysis,R,Nlp,Opennlp,Text Analysis,我试图使用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 ",
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)
require(“NLP”)
##一些文本。
s尝试将您的自定义模型en ner customperson.bin
放在您的工作目录中。然后指定Maxent\u Entity\u Annotator
的model
参数,如下所示:
entity_annotator <- Maxent_Entity_Annotator(model = "en-ner-customperson.bin")
实体注释器也许这是一个开始