我是R编程中的新蜜蜂,请你帮我解决下面给出的代码中的错误:
#import library
library(NLP)
library(tm)
library(wordcloud)
library(SnowballC)
library(slam)
library(lsa)
#import text files for preprocessing
text_key<-(Corpus(DirSource('V:\\Work\\R\\Input\\answer_key')))
##pre-processing is started
#do pre-processing of text data of answer
text_key <- tm_map(text_key, stripWhitespace)
text_key <- tm_map(text_key,content_transformer(tolower))
text_key <- tm_map(text_key,removeWords, stopwords("english"))
text_key <- tm_map(text_key, removeNumbers)
text_key <- tm_map(text_key, removePunctuation)
#do stemming of douments
text_key <- tm_map(text_key,stemDocument,language="english")
text_key <- tm_map(text_key, stripWhitespace) # *Stripping whitespace
text_key <- tm_map(text_key, PlainTextDocument)
#generate document term matrix
dtm_key <- DocumentTermMatrix(text_key)
#print the output of documenttermmatrix
dtm_key
# #inspect the element in document term matrix
inspect(dtm_key)
# #generate wirdcoud for twi dicument term matrix for answer-sheets
m <- as.matrix(dtm_key)
am <- lw_logtf(am) * gw_idf(am)
space <- lsa(am, dims = dimcalc_raw())
我必须使用LSA将我的矩阵生成到语义空间,但我面临着SVD订阅错误的错误。
答案 0 :(得分:0)
这是一个愚蠢的错误,需要改为
# #generate wirdcoud for twi dicument term matrix for answer-sheets
m <- as.matrix(dtm_key)
am <- lw_logtf(am) * gw_idf(am)
我将变量更改为“am”替换为“m”变量。
am <- lw_logtf(m) * gw_idf(m)
这是变更变量,我解决了。