Predict your next Word

Aleksada
08/21/2015

An Example

Introduction

  • This Shiny App is designed to predict the next word given users' entered words sequence based on Katz's Back-off algorithm
  • The training data in our prediction model comes from twitter, blog, and news provided by SwiftKey
  • The predictive method based on four-grams model, which is a special case of n-gram model.

Description of the My Algorithm

To predict the next word of the specified sentence

  • First clean the given sentence, such as deleting the non-letter character and altering all word to lower case.
  • Use a FourGram; the first three words of which are the last three words of the user provided sentence for which we are trying to predict the next word.
  • If no FourGram is found, we back off to ThreeGram.
  • Similarly, if no Three-Gram is found, try Two-Gram, then One-Gram.

Example Prediction of Three-Gram and Four-Gram

Sample Input: “How are”

Three-grams

  nextTerm Counts
1      you     95
2        u     13
3   things     10
4       we      7
5       ya      6

Sample Input: “How are you”

Four-grams

     nextTerm Counts
1 celebrating      9
2       doing      9
3       today      7
4         all      5
5     feeling      5

Instruction of My Shiny App

An Example

Following the figure, enter the imcomplete sentence following which you want to predict the next word in the sidebar “Enter your sentence here” and then click the button “Obtain your next word”, you can get the word that is the most probable to follow your sentence as well as a word cloud of at most 50 next-word with high frequency.