Next Word Prediction

Umesh Rijal
August 2026

An NLP-powered text prediction application

Data Science Capstone

Built using:

  • R
  • Quanteda
  • Shiny
  • SwiftKey English corpus

Objective: Predict the most likely next word from a phrase entered by the user.

The Problem

Why Next Word Prediction?

Typing assistance can improve the speed and convenience of text input.

Our objective

  • Accept a phrase from the user
  • Analyze the preceding words
  • Predict the most likely next word
  • Return the prediction through an interactive Shiny application

Training Data

The model uses the English SwiftKey corpus:

  • Blogs
  • News
  • Twitter

A 1% sample was used to balance model coverage and application performance.

The Algorithm

N-gram Language Model

The prediction engine uses a backoff strategy:

4-gram
   ↓
3-gram
   ↓
2-gram
   ↓
Unigram