Predictive Keyboard

Rodrigo Araujo
30/12/2016

What is this project about?

In this project, I developed a predictive keyboard app. This app suggests to the user the next word based on previous typed words. This app can be very useful for:

  • communication,
  • or any note taking application.

How does it work?

This app is created based on a n-gram language model, which assigns probabilities to words conditional to sequences of previous seen words. More specifically, the Katz backoff model was used. This model relies on a discounted probability P if an N-gram has been seen before. Otherwise, it recursively backs off to the Katz probability for the shorter-history (N-1)-gram, as discribed in [1].

  • Starts with a 4-gram
  • if we find one in the first terms of 4-gram, return most frequent term probability
  • if not, check 3-gram, then 2-gram respectively
  • Distribute left-over probability to the lower order probabilities

[1] http://web.stanford.edu/~jurafsky/slp3/4.pdf

How is the performance?

The model was trained on about 1% of the data, and tested on the rest. The performance of the model is about 10%, which is calculated as the percentage of correctly predicted words, and it is based on a 4-gram model.

How does it work?

This is a very simple app to use. The first time you open the app, it will take a few seconds to load and be ready for you. However, once it is loaded, it is very fast to predict your next word. To test the app simply follow these steps:

  1. Go to https://sineco.shinyapps.io/PredictiveKeyboard/
  2. Wait about 10 seconds to load the first time (you will see double quotes when it is ready)
  3. Enter a text on the side panel
  4. Click the ok Go! button
  5. The suggested word will be shown on the main panel with an assigned probability.