I would like to replace every word in my corpus that contains 'kind' with 'Kindertoekomst'. I can do it normally:
Woorden<-c("kinderen", "kleinkind")
Woorden[grepl("kind", Woorden)]<-"Kindertoekomst"
But I would like to do it within my Corpus.
I managed to do this with
Kind<-grepl("kind", Woorden)
docs <- tm_map(docs, function(x) stri_replace_all_fixed(x, Woorden[as.logical(Kind)], "kindertoekomst", vectorize_all = FALSE))
But then I can't use other functions anymore:
dtm <- DocumentTermMatrix(docs)
Error: inherits(doc, "TextDocument") is not TRUE
And corpus_clean <- tm_map(docs, content_transformer(tolower)) Error in UseMethod("content", x) : no applicable method for 'content' applied to an object of class "character"
Please help me :)