A Shiny application that predicts the next word from an English phrase.
Build a simple and interactive next-word prediction system using an n-gram language model.
Technologies: R • Shiny • Stringr
The model uses samples from three English text sources:
The application uses the last two words of the input phrase to search for a likely next word.
Step 1: Try a trigram based on the last two words.
Step 2: If no match exists, use a bigram based on the last word.
Step 3: If no match exists, return the most frequent word in the corpus.
The most frequently observed candidate is selected.
The user enters an English phrase and clicks Predict Next Word.
Input:
I want to
Prediction:
be
The application provides the prediction interactively through a simple Shiny interface.
The model successfully generates predictions for different English phrases.
| Input | Prediction |
|---|---|
| I want to | be |
| In the | world |
| We are | going |
| This is | a |
| People are | going |