thushara tom
thushara tom

Reputation: 71

Error in OpenNLP package - dataframe coercing

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

Answers (2)

Jurian-K
Jurian-K

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

Rafa
Rafa

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

Related Questions