0
「TermDocumentMatrix」を使用できないのはなぜですか?「TermDocumentMatrix」を使用できないのはなぜですか?
複数の単語を単数形で統一するために次のコマンドを使用しましたが、エラーが発生します。
crudeCorp <- tm_map(crudeCorp, gsub, pattern = "smells", replacement = "smell")
crudeCorp <- tm_map(crudeCorp, gsub, pattern = "feels", replacement = "feel")
crudeDtm <- TermDocumentMatrix(crudeCorp, control=list(removePunctuation=T))
Error in UseMethod("meta", x) :
no applicable method for 'meta' applied to an object of class "character"
どうすれば解決できますか? 1.単数から清掃に変更するコマンドはありますか? 2.このコマンドは間違って使用されていますか?
私は、文章処理と行列に次のコードを添付します。
library(tm)
library(XML)
crudeCorp<-VCorpus(VectorSource(readLines(file.choose())))
#(Eliminating Extra Whitespace)
crudeCorp <- tm_map(crudeCorp, stripWhitespace)
#(Convert to Lower Case)
crudeCorp<-tm_map(crudeCorp, content_transformer(tolower))
# remove stopwords from corpus
crudeCorp<-tm_map(crudeCorp, removeWords, stopwords("english"))
myStopwords <- c(stopwords("english"), "can", "will","got","also","goes","get","much","since","way","even")
myStopwords <- setdiff(myStopwords, c("will","can"))
crudeCorp <- tm_map(crudeCorp, removeWords, myStopwords)
crudeCorp<-tm_map(crudeCorp,removeNumbers)
crudeCorp <- tm_map(crudeCorp, gsub, pattern = "smells", replacement = "smell")
crudeCorp <- tm_map(crudeCorp, gsub, pattern = "feels", replacement = "feel")
#-(Creating Term-Document Matrices)
crudeDtm <- TermDocumentMatrix(crudeCorp, control=list(removePunctuation=T))
例:私のデータ
1. I'M HAPPY
2. how are you?
3. This apple is good
(skip)