Jose Ramon Pineda
20/Aug/2020
https://jrpineda.shinyapps.io/wordpred/.
This program will guess a single word based on the words the user has inputted into the predictor.
How to use this app:
Fairly simple, just start typing words!
If you type an unknown word or a typo, the program will encourage you to keep typing so that the predictor can find a word it identifies.
Simply type as long as you want. The program will pay attention to the most recent words in the string.
Strengths:
Quick to load.
Fast predictions.
Simple code.
Weaknesses:
Due to size limitations I could only use a fraction of the created bigrams and trigrams.
Limited to bigrams and trigrams, ideally would like to use tetragrams, machine learning techniques, and Kneser Smoothing.
Hopefully this app works correctly for you, if not obviously let me know in the comments. The code is not too complex (I post a sample of it below). I mainly used tidy text principles from Silge and Robinson's textbook to create the bigrams and trigrams, then trimmed those down to be 25MB .csv files that could be processed quickly.
Anyway, we're done with the program! Congrats to all of us who made it this far.
-JRP
wordPred <- function(string){
if(str_count(string, '\\s+') > 1){
predict <- trigrams %>%
filter(word2 == word(string, -1)) %>%
arrange(desc(combo)) %>%
slice(1)
if(is_empty(predict$word3)){
print("Keep Typing...")
} else {
return(predict$word3)
}
}}