I have the following code:
library(tm)
text<-readLines("anyText.txt")
corpus<-Corpus(VectorSource(text))
corpus<-tm_map(corpus,content_transformer(tolower))
inspect(corpus)
corpus<-tm_map(corpus,removePunctuation)
stopwords<-c(stopwords('english'),"available","via")
corpus<-tm_map(corpus,removeWords,stopwords)
tempCorpus<-corpus
inspect(tempCorpus)
library(ctv)
library(SnowballC)
corpus<-tm_map(corpus,stemDocument)
inspect(corpus)
corpusT<- tm_map(corpus, PlainTextDocument)
corpusT<-tm_map(corpusT,stemCompletion,dictionary=tempCorpus)
dtm<-TermDocumentMatrix(corpusT,control=list(minWordLength=1))
but I got the error:
Error: inherits(doc, "TextDocument") is not TRUE
I found that when I comment the line:
corpusT<-tm_map(corpusT,stemCompletion,dictionary=tempCorpus)
the program works fine, but for what I know that last line is for updating the list of steem words with the ones I got in tempCorpus so I need it.
How can I correct that error?