2

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?

MrFlick
  • 195,160
  • 17
  • 277
  • 295
PoWei
  • 21
  • 2
  • Please provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data. Also, are all those steps necessary to reproduce the problem? Try to make your code as *minimal* as possible. – MrFlick Jun 10 '15 at 13:56
  • Is it possible that stemCompletion is the function causing the problem? Can you remove it and see if it works? – Joshua Rosenberg Jun 16 '15 at 04:01
  • I removed the stemCompletion function and it worked. Thanks! – PoWei Jun 18 '15 at 06:38

0 Answers0