The app uses a backoff n-gram model:
- Clean input by lowercasing text and removing punctuation
- Try a trigram match using the last two words
- If unavailable, back off to a bigram match using the last word
- If still unavailable, return the most common unigram
The prediction is selected from the most frequent next-word candidate for the matched context.
This backoff design ensures the app returns a prediction even for unfamiliar phrases.