Jacky Wong Kae Perng
April 14 2015
The “Text Prediction” Shiny app provides the means to predict the next word based on the input of a word or a phrase by users. Next word prediction is particularly useful to suggest terms when one types on mobile devices. This presentation will detail the features, prediction algorithms and the implementation details of the application.
URL Links : App Location | GitHub | RPubs | Data Source
Screenshot of the app:
Behind the scene, Shiny App perform the following:
Eg. The trigram with “have to xx” frequency table:
| Trigram | Frequency |
|---|---|
| “have to get” | 50 |
| “have to be” | 40 |
| “have to say” | 30 |
| “have to go” | 20 |
| “have to take” | 10 |
| “have to die” | 5 |
When user enters “have to”, the app will look for Trigram with “have to” and compute the cond. probability of the third word given the preceding two words, i.e. “have to”.
Using the previous example, the appl will compute the following conditional probability.
| Cond. Probability | Probability |
|---|---|
| p(“get”/“have to”) | 50/(50+40+30+20+10+5)= 0.32 |
| p(“be”/“have to”) | 40/(50+40+30+20+10+5)= 0.26 |
| p(“say”/“have to”) | 30/(50+40+30+20+10+5)= 0.19 |
| p(“go”/“have to”) | 20/(50+40+30+20+10+5)= 0.13 |
| p(“take”/“have to”) | 10/(50+40+30+20+10+5)= 0.06 |
| p(“die”/“have to”) | 5 /(50+40+30+20+10+5)= 0.03 |
Based on the probibility computed, the top 5 highest probability of the next word given “have to” are:“get”, “be”, “say”, “go”, “take” in that order. The word “die” does not make it to the top 5 and hence is not displayed to the user.
The result will be displayed as follow:
User can also click on the documentation tab:
Limitation: