We use machine learning to predict the next word based on a Twitter data set that is part of the sbo library. The user is asked to input a phrase. At the beginning no word is inside the text box, so our algorithm assumes 0 words, and predict the word number 1. When a word is written, the algorithm predicts the second word. When two words are written by the user, the algorithm predicts the word number 3. And so on. There is no limit for the number of words.
You can find my Shiny App on https://illyabjazevic.shinyapps.io/shinyapp/
The app creates a table with many possible options and the probability of each one.