Word predictor app

Mariana Martins

22/08/2022

Context

The goal of this exercise is to create a product to highlight the prediction algorithm that you have built and to provide an interface that can be accessed by others. For this project you must submit:

A Shiny app that takes as input a phrase (multiple words) in a text box input and outputs a prediction of the next word.
A slide deck consisting of no more than 5 slides created with R Studio Presenter (https://support.rstudio.com/hc/en-us/articles/200486468-Authoring-R-Presentations) pitching your algorithm and app as if you were presenting to your boss or an investor.

Algorithm used do predict

predictWord <- function(the_word) {

word_add <- stripWhitespace(removeNumbers(removePunctuation(tolower(the_word),preserve_intra_word_dashes = TRUE)))

# testing print("word_add")

the_word <- strsplit(word_add, " ")[[1]]

# testing print("the_word")

n <- length(the_word)

# testing print(n)

#check Bigram

if (n == 1) {the_word <- as.character(tail(the_word,1)); functionBigram(the_word)}

#check trigram

else if (n == 2) {the_word <- as.character(tail(the_word,2)); functionTrigram(the_word)}

#check quadgram

else if (n >= 3) {the_word <- as.character(tail(the_word,3)); functionQuadgram(the_word)}

}

How the app works

  1. The first task is to load the libraries.

  2. Next we load the bigram, trigram and quadgram frequencies words matrix frequencies

  3. Next we use the function to predict the word.

  4. Then we use the function predictWord

Experience using the app

  1. The app uses the correct prediction algorithm for words prediction

  2. The results shown uses the functions for prediction.

Thank you