2025-08-05

What is the Problem?

  • Typing on mobile devices can be slow and error-prone
  • Predictive text helps users type faster and more accurately

Can we build a lightweight, responsive next-word predictor using R?

Our Solution: A Shiny Web App

  • Accepts user input of a phrase
  • Predicts the most probable next word
  • Powered by cleaned SwiftKey dataset and n-gram models

Uses a backoff algorithm for prediction

How the Model Works

  • Text corpus cleaned: lowercase, punctuation removal, whitespace trim
  • N-grams generated:
    • Unigrams, Bigrams, Trigrams
  • Prediction Logic:
    • If trigram match: return word3
    • Else bigram match: return word2
    • Else: return most frequent unigram

```r predict_next_word(“I am”, …) # returns: “going”