Farhan Bin Hossain
2026-08-16
Problem: Typing on mobile is slow and error-prone
Solution: A next-word prediction app trained on real English text — just like SwiftKey
Try it: https://jjvqgo-farhan-bin.shinyapps.io/next-word-predictor/
Stupid Backoff N-gram Model — 4 layers of prediction:
User types → check QUADGRAMS (3,707,806 sequences)
No match? → check TRIGRAMS (2,997,658 sequences)
No match? → check BIGRAMS (1,361,416 pairs)
No match? → fallback to most common UNIGRAMS
Example:
This ensures a prediction is always returned — never blank!
| Source | Lines | Avg Words Per Line |
|---|---|---|
| Blogs | 899,288 | 42 words |
| News | 1,010,242 | 35 words |
| 2,360,148 | 12 words |
Total N-grams built:
Data was lowercased, punctuation removed and symbols stripped before training
3 simple steps:
Live demo results:
| Phrase | Top Prediction |
|---|---|
| happy new | year |
| I was going to | be, happen |
| the president of the | united |
| I want to go | back, out |
| thanks for the | follow, mention |
What was built:
Links:
Johns Hopkins Data Science Capstone — Farhan Bin Hossain