I am using tm package in R to do stemming in my corpus. However, I got a problem when I ran DocumentTermMartix
"Error in UseMethod("meta", x) : no applicable method for 'try-error' applied to an object of class "character"
here is my workflow:
library(tm)
myCorpus <- Corpus(VectorSource(training$FullDescription))
myCorpus <- tm_map(myCorpus, content_transformer(tolower), lazy=TRUE)
myCorpus <- tm_map(myCorpus, removePunctuation, lazy=TRUE)
myCorpus <- tm_map(myCorpus, removeNumbers, lazy=TRUE)
myStopwords <- c(stopwords('english'), "available", "via")
myCorpus <- tm_map(myCorpus, removeWords, myStopwords, lazy=TRUE)
dictCorpus <- myCorpus
myCorpus <- tm_map(myCorpus, stemDocument, lazy=TRUE)
myCorpus <- tm_map(myCorpus, stemCompletion, dictionary=dictCorpus, lazy=TRUE)
myDtm <- DocumentTermMatrix(myCorpus, control=list(wordLengths=c(1, Inf),
bounds=list(global=c(floor(length(myCorpus)*0.05), Inf))))
I tried to use the 'global bounds' argument to limit the number of terms like the last row of my code, but I still can't solve this problem. How do I solve this problem?