我正在关注这篇文章https://mylearnmachinelearning.com/category/linear-regression/来创建一个命名实体提取器。如需要,我安装了所有openNLP
,NLP
,rJava
,magrittr
和openNLPmodels.en
包。除了使用这个功能annotations
时,所有人都去了计划。
# Extract entities from an AnnotatedPlainTextDocument
entities <- function(doc, kind) {
s <- doc$content
a <- annotations(doc)[[1]] #Point of error
if(hasArg(kind)) {
k <- sapply(a$features, `[[`, "kind")
s[a[k == kind]]
} else {
s[a[a$type == "entity"]]
}
}
通过使用这个:
entities(text_doc, kind = "person")
。
事情是甚至RStudio中的intellisense似乎不知道任何功能annotations
。它显示annotation
,annotate
和annotations_in_spans
什么不是,但没有annotations
。
甚至有一个YouTube video也证明了这一点。奇怪的是他能够在那里使用annotations
。
包装版本:
在早期版本的annotations
包中,AnnotatedPlainTextDocument
方法与NLP
类型的对象相关联。
Here is the documentation版本0.1-11。
The latest NLP version是0.2-0。
The method for AnnotatedPlainTextDocument现在被称为annotation
(最后没有'')。从文档中看,它的主要区别在于它返回一个Annotation
对象,而不是Annotation
对象列表。
功能annotations
有很多包,请看这里:https://www.rdocumentation.org/search?q=annotations
虽然可能不是最好的方法,但如果您在不知道该功能属于哪个软件包的情况下寻找特定功能,该网站可能会帮助您找到这样的软件包。