Error in UseMethod(“meta”, x) : no applicable method for 'try-error' applied to an object of class “character”

…衆ロ難τιáo~ 提交于 2019-12-06 11:35:40

问题


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?

来源:https://stackoverflow.com/questions/30757856/error-in-usemethodmeta-x-no-applicable-method-for-try-error-applied-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!