SwiftKey Next Word Prediction Application

Building a predictive text application using SwiftKey text data.

The goal of this project is to predict the next word a user is likely to type based on a given phrase.

SwiftKey data sources:

  • Twitter text
  • Blog text
  • News text

The final product is an interactive Shiny application that accepts a phrase and suggests the next word.


Data Exploration

The dataset contains more than 4 million text entries.

Summary of the training data:

Dataset Lines Average Words per Line
Twitter 2,360,148 12.75
Blogs 899,288 41.75
News 1,010,206 34.41

Key findings:

  • Twitter contains shorter conversational text.
  • Blogs and news contain longer written sentences.
  • The variety of writing styles helps create a more general prediction model.

Prediction Algorithm

The application uses an n-gram language model.

Text Processing:

  1. Convert text to lowercase
  2. Remove punctuation and numbers
  3. Remove unnecessary spaces
  4. Create word combinations

Prediction Method:

  • Trigrams are used first to find the most specific match.
  • If no trigram is available, the model uses bigrams.
  • The most frequent next word is returned as the prediction.

Ex: Input: I love Prediction: you


Shiny Application

The Shiny app provides a simple interface for users.

How it works:

  1. User enters a phrase into the text box.
  2. The app cleans the input.
  3. The prediction model searches learned word patterns.
  4. The application displays one predicted next word.

The app is designed to provide a quick and easy predictive typing experience.


Results and Future Improvements

Current Results:

  • Successfully predicts possible next words.
  • Uses a lightweight model for fast responses.
  • Provides an interactive user interface.

Future Improvements:

  • Train on a larger dataset
  • Use more advanced language models
  • Improve prediction accuracy
  • Add multiple prediction suggestions

Thank You