尝试使用tm_term_score为行中的文本将术语短语或术语对评分为1或0时出现此错误:
c1 <- Corpus(VectorSource(r1))
inspect(c1)
inspect(c1[2])
cleanR1 <- tm_map(c1, removeWords, stopwords('english'))
cleanR1 <- tm_map(cleanR1, content_transformer(tolower))
cleanR1 <- tm_map(cleanR1, removeWords, c("re", "ve", "ahha"))
cleanR1 <- tm_map(cleanR1, removePunctuation)
cleanR1 <- tm_map(cleanR1, removeSpecialChars)
cleanR1 <- tm_map(cleanR1, removeNumbers)
cleanR1 <- tm_map(cleanR1,removeWords,stopwords('en'))
cleanR1 <- tm_map(cleanR1,stripWhitespace)
cleanR1 <- tm_map(cleanR1,stemDocument)
cleanR1 <- tm_map(cleanR1, PlainTextDocument)
tm_term_score(cleanR1, terms, FUN = slam::row_sum)
UseMethod(“tm_term_score”,x)中的错误: 没有适用于'tm_term_score'的方法适用于类“c('VCorpus','Corpus')的对象”
STR(术语) chr [1:61]“帮助学习”“帮助成长”。
答案 0 :(得分:1)
您需要将PlainTextDocument
,termFreq
返回的字词频率或TermDocumentMatrix
传递给tm_term_score
的第一个参数,而不是语料库。
使用术语文档矩阵的示例:
tdm <- TermDocumentMatrix(cleanR1)
tm_term_score(tdm, terms, FUN = slam::row_sum)
请参阅文档?tm::tm_term_score