SwiftKey Next Word Prediction

Mohamed Sameer

1. Project Overview

SwiftKey Next Word Prediction

An intelligent text prediction application using Natural Language Processing

  • Developed using R programming.
  • Uses text data from blogs, news and Twitter.
  • Predicts the next word based on the words entered by the user.
  • Provides an interactive interface using Shiny.

Project Goal: To make text entry faster and easier through next-word prediction.

2. Data Collection and Preparation

Understanding the Data

The project uses three English text datasets:

  • US Blogs
  • US News
  • US Twitter

Data Preparation Steps

  1. Loaded the three text datasets.
  2. Selected 30,000 lines from each dataset.
  3. Combined them into 90,000 text lines.
  4. Converted text into lowercase.
  5. Removed URLs, punctuation and unnecessary characters.
  6. Tokenized the cleaned text for analysis.

3. Prediction Algorithm

N-gram Language Model

The application uses two types of n-grams:

  • Bigram: Uses the previous one word to predict the next word.
  • Trigram: Uses the previous two words to predict the next word.

Prediction Strategy

  1. Clean the user’s input.
  2. Check the last two words against the trigram model.
  3. If no match is found, check the last word against the bigram model.
  4. If no match is found, return the most common word.

Example:

Input: I want to

Predicted word: be

4. Application Development

Interactive Shiny Application

The application was developed using R and Shiny.

Main Features:

  • Simple and user-friendly interface.
  • Text input for entering sentence fragments.
  • Predict Next Word button.
  • Displays the predicted next word.
  • Lightweight prediction model for deployment.

Technologies Used

  • R Programming
  • RStudio
  • Quanteda
  • Shiny
  • N-gram Language Modeling

5. Deployment and Conclusion

Live Application

The project was successfully deployed using ShinyApps.io.

Try the application:

https://swiftkey-predictor-2026.shinyapps.io/swiftkey_final_project/

Conclusion

  • Successfully developed a next-word prediction model.
  • Applied text cleaning and NLP techniques.
  • Implemented bigram and trigram prediction.
  • Created and deployed an interactive web application.

Thank You!