Next-Word Prediction App in Shiny

Javier Eslava-Schmalbach
11/25/2018

Next-Word Prediction App

  • This app works predicting the next word after inputing the user text on the side bar panel box on the app
  • The app estimates and sorts next possible words, based on scores, using the stupid backoff algorithm.
  • In easy words, developed functions divide sentences in n-grams from 1 to 5 words, and the last word on the n-gram is the predicted word of the previous ones. In the case of empty words, the sorted frequency of one word n-gram (scored) was used as the expected word to be used by the user.
  • A dictionary of sentences was built from Coursera Task text files that included Blogs, News and Tweets texts in US_english. (download linked file buttom)
  • The dictionary was cleaned before building n-grams. Bad words were excluded using this file (download linked file buttom)

-Other packages that I used were:

    - catTools
    - Shiny
    - tidyr
    - readR
    - corpus
    - NLP
    - tm
    - imager
    - magick

The App

plot of chunk image

If you want to go to the App, click on the image. Use the go-back buttom of the browser, to return to the presentation.

Just write on the box the words from which you want to obtain the prediction of the next word.

The App will suggest you, with their respective scores, the main possible words you could use. The histogram, at the front, will show you the same information graphically.

Manually, you can find the App at (https://jheslavas.shinyapps.io/Next_Word_Prediction)

Acknowledgments

  • To the people involved in the Coursera course at Coursera and at Jhons Hopkins University. It has been a great experience.

  • This exercise was based on packages and theoretical bases of openNLP, RTextTools, RWeka, and ngram. Some functions were modified from Akselix at Github