Word Prediction Shiny App

Marta Z. Naves Sánchez
05/05/2026

Overview of the Application

Slide 1: Project Overview

This project is a Next Word Prediction Shiny Application.

  • Built using R and Shiny
  • Uses an n-gram language model
  • Predicts the most likely next word based on user input
  • Designed as an interactive text prediction tool similar to mobile keyboards

Slide 2: Algorithm Description

The prediction system is based on a backoff n-gram model:

  • 4-gram → 3-gram → 2-gram → unigram fallback
  • Uses frequency counts from a large text corpus (Twitter, blogs, news)
  • Applies weighted scoring:
    • Higher weight to longer context (4-gram strongest)
    • Smoothing using log-frequency
    • Unigram used only when no context match exists

This ensures:

  • Context awareness
  • Stability in prediction
  • Reduced randomness

Slide 3: App Functionality

The Shiny app includes:

  • Text input box for user phrase
  • Slider to select number of predictions
  • “Predict” button for execution
  • Output of top predicted words
  • Test dataset for evaluation of performance

How it works:

  • 1. User enters a phrase
  • 2. System extracts last words
  • 3. Matches n-grams
  • 4. Returns ranked predictions

Slide 4: User Experience

The app behaves like a lightweight predictive keyboard.

Experience characteristics:

  • Fast response time (~instant prediction)
  • Simple and clean interface
  • Context-aware suggestions
  • Sometimes general words appear when context is limited

Strength:

  • Easy to use and intuitive

Limitation:

  • Performance depends on training data quality and size

Slide 5: Evaluation & Conclusion

Strengths:

  • Clear probabilistic language model
  • Interactive Shiny interface
  • Real-time prediction capability
  • Lightweight and deployable on shinyapps.io

Novelty:

  • Combines classical NLP (n-grams) with interactive UI
  • Demonstrates full pipeline: data → model → app

This project demonstrates:

  • Solid understanding of NLP fundamentals
  • Ability to build and deploy data products
  • Practical engineering with R Shiny