eulerwang
3/14/2017
To get the Swift Prompt work , There four necessary steps:
#after sample the data , tidy the data
tokens <-quanteda::tokenize(toLower(dataset), removeNumbers = TRUE, removePunct = TRUE, removeSeparators = TRUE, removeTwitter = TRUE, removeHyphens = TRUE ,stem=TRUE)
# ngrams with parameter 2 , and then transform the result to dataframe
bigrams <- data.table(as.data.frame(table(unlist(quanteda::ngrams(tokens, n=2)))))
#for the filtering operation ,separate the words
colnames(bigrams) <- c('bigram','n')
bigrams <- separate(bigrams,bigram, c("word1","word2"),sep="_")
you can input a phrase , the shiny server will split your phrase to words , then get the last word , the last word will filter the bigrams data , get the next word distribution
the display will show your word prompt by bar graph and star graph . in addtion , the app will always show the bar graph and star graph on top 30 bigrams data .