Please consider the following sample:
library(RXKCD) library(tm) library(wordcloud) scores = c(2, 7, 5, 4, 4, 6, 8) feedback = c("Cant connect", "Excellent Service but i had trouble with login", "Need more locations", "Trouble with connection", "Cant connect", "Login issues", "You need more locations") df = data.frame(scores, feedback) my.corpus <- Corpus(DataframeSource(data.frame(df))) #my.corpus <- tm_map(my.corpus, tolower) my.corpus <- tm_map(my.corpus, content_transformer(tolower)) tdm <- TermDocumentMatrix(my.corpus) m <- as.matrix(tdm) v <- sort(rowSums(m),decreasing=TRUE) corpus <- tm_map(corpus, content_transformer(tolower)) d <- data.frame(word = names(v),freq=v) #---some more intelligent means of counting phrases here?
From this data set I will be creating a word cloud (the mechanics of which I have worked out already).
Using this example, I am looking to pre-process the data such as that rather than single words like 'Cant' and 'locations' appearing largest, phrases like 'Cant connect' and 'more locations' would appear largest. In other words, I am looking for a way to more intelligently count the frequency of multi-word strings rather than single words alone. Is there a method of using natural language processing (or otherwise) to count frequencies of meaningful phrases rather than single words?
Please forgive any errors in Cross Validated posting protocol and thank you for any input!