2026-01-13

Next Word Predictor

Author: Mahavir Rajpurohit
Date: 2026-01-13

Problem & Goal

Problem
Typing content takes time. Predicting the next word can improve writing speed.

Goal
Build a Shiny app that predicts the next word using an n-gram language model.

Algorithm & Model

Approach - Build a text corpus - Tokenize text into bigrams (two-word sequences) - Count bigram frequencies - Extract last word from user input - Predict the most frequent next word

Tools Used - R (tidyverse, tidytext) - Shiny

Shiny App Features

  • Text input box for phrase
  • Button to trigger prediction
  • Displays single predicted next word

Example

Input