I'm using the tm package in r. Everything works properly until I include the stemCompletion. I'm getting the following error:
Error in grep(sprintf("^%s", w), dictionary, value = TRUE) :
invalid regular expression
My code is as follows:
path = '~/Interviews/Transcripts/'
file.names <- dir(path, pattern = '.txt')
corpus = lapply(seq_along(file.names), function(index) {
fileName = file.names[index]
filePath = paste(path, fileName, sep = '')
transcript = readChar(filePath, file.info(filePath)$size)
transcript <- gsub("[’‘^]", '', transcript)
corpusName = paste('transcript', index, sep = "_")
c <- Corpus(VectorSource(transcript))
DublinCore(c[[1]], 'Identifier') <- paste(index, fileName, sep ='_')
meta(c, type = 'corpus')
c <- tm_map(c, stripWhitespace)
c <- tm_map(c, content_transformer(tolower))
c <- tm_map(c, removeWords, c(stopwords("english"), 'yeah', 'yep'))
c <- tm_map(c, removePunctuation)
c <- tm_map(c, stemDocument)
c <- tm_map(c, stemCompletion, c)
c <- tm_map(c, PlainTextDocument)
c
})