2026-09-26

The Problem

  • Typing on mobile devices is slow and error-prone
  • A predictive keyboard (like SwiftKey) speeds this up by guessing your next word
  • Goal: build a working next-word predictor and deploy it as a live web app

The Data

  • Trained on real English text: blogs, news, and Twitter posts
  • Explored word frequency, line length, and vocabulary coverage first
  • Found that a few thousand common words cover 90% of everyday text — key to keeping the model small and fast

The Algorithm

  • Built an n-gram model: learns which words commonly follow 1, 2, or 3 previous words
  • Uses a backoff strategy: tries the longest matching phrase first (4-gram), falls back to shorter phrases (3-gram, 2-gram) if no match is found
  • Kept only the top 3 most likely next words per phrase — keeps the model small and fast enough for instant predictions

The App

  • Built with R Shiny, deployed live at: https://saurabhgupta.shinyapps.io/nextWordPredictor/
  • Simple interface: type a phrase, click Predict, see the top next-word suggestion instantly
  • Example: typing “i went to the” → predicts “bathroom” (with “doctor” and “front” as alternates)

Reflections & Next Steps

  • The model reflects real, sometimes informal, language patterns (e.g., Twitter slang like “rt”, “ff”)
  • Tradeoff made: prioritized speed and small model size over maximum accuracy
  • Future improvements: larger training sample, smarter smoothing, spelling correction