title: "Next Word Prediction App" author: "doctahmanhattan" date: "07/27/2024" output: ioslides_presentation ---
Text input for phrase.
Predicts the next word.
Deployed on shinyapps.io.
``` library(shiny) library(tidyverse)
ui <- fluidPage( titlePanel("Next Word Predictor"), sidebarLayout( sidebarPanel( textInput("text", "Enter a phrase:", ""), actionButton("predictButton", "Predict Next Word") ), mainPanel( textOutput("prediction") ) ) )
predictnextword <- function(input_text) { # Implement your prediction algorithm here # For example, using n-gram model return("example") # Replace with actual predicted word }
server <- function(input, output) { observeEvent(input$predictButton, { output$prediction <- renderText({ req(input$text) predictedword <- predictnextword(input$text) paste("Next word prediction:", predictedword) }) }) }
shinyApp(ui = ui, server = server) ```
Phrase: "I love to"
Prediction: "read"
Phrase: "This is a"
Prediction: "test"