Final Project Submission: Text Prediction

zgdiao
October 15 2021

Introduction

This presentation introduces the functionality of the Shiny app we have created for the text prediction, and highlights the prediction algorithm used by the app.

To access the interface of the Shiny app, please visit:

https://zgdiao.shinyapps.io/Prediction_Algorithm/

PS: It would take some time to load the data, please be patient.

Functionality 1

  • predict the next word after entering a phrase and space in the input box

interface

  • complete a word based on the context or the frequency of use of the words when entering letters

complete

Functionality 2

  • filter out special characters

special characters

  • adjust the maximum number of displayed results total number

Implementation of the Prediction Algorithm

  • use regular expressions to filter out special characters in the input phrase
  • build a basic n-gram model (2-gram, 3-gram, and 4-gram) based on data from blog, news, and twitter
  • improve the n-gram model by merging models from the iWeb corpus (see https://www.ngrams.info/iweb.asp)
  • predict the next word in turn according to the previous 3, 2, or 1 words
  • build a 1-gram model, which records the frequency of use of a single word
  • complete the word being typed based on the n-gram model