Final Project Submission- Word Prediction -
17.11.2017
A Shiny app that takes as input a phrase (multiple words) in a text box input and outputs after a suitable delay a prediction of the next word.
Data basis are US blogs, news, and twitter data downloaded from: https://d396qusza40orc.cloudfront.net/dsscapstone/dataset/Coursera-SwiftKey.zip
For preprocessing the data the library “ngram” is used and the blogs, news and twitter data is loaded.
Then all 2-grams are build and their frequencies are calculated. Now we can apply the word predicting function.
Core of the app is a function that takes the last word of the text input, searches the 2-gram with this word as startword and the highest frequency. Then the second word of this 2-gram is displayed.
If no corresponding 2-gram is found, the text “Sorry, no suggestion” is displayed.
The user types a word or sentence in the text box on the left, then after using the button “Predict next word” the predicted word is displayed on the right side.