Reputation: 71
I am trying to run a basic sentence annotation function and I keep running into the same error.
The code I tried to use is:
s <- as.String(cleandata) #cleandata is my data.It is a character class.
sent_ann <- Maxent_Sent_Token_Annotator()
a2 <- annotate(s,sent_ann)
The above code keeps generating the error:
Error in as.data.frame.default(x[[i]], optional = TRUE) :
cannot coerce class "c("Simple_Sent_Token_Annotator", "Annotator")" to a data.frame
What do I do ?
Upvotes: 3
Views: 1830
Reputation: 11
I had the same error. In my case the tidyverse library was overwriting the annotate function from NLP. This should work:
library(NLP);
library(openNLP);
Upvotes: 1
Reputation: 51
I was getting your same error, doing exactly the same. Then I restarted R-studio, I loaded the libraries
library(NLP);
library(tm);
library(openNLP);
library(openNLPmodels.en);
and I could execute the statement successfully.
Upvotes: 5