Problem

SwiftKey users often type phrases quickly on mobile devices.

The goal of this project is to predict the next word based on a phrase entered by the user.

The application provides a simple demonstration of next-word prediction using text data.

Data

The model uses sample text from three sources:

  • Blogs
  • News
  • Twitter

For this project, 5,000 lines were sampled from each source to keep the application lightweight.

Algorithm

The application uses a simple word-frequency approach.

  1. The user’s phrase is converted to lowercase.
  2. The last word is identified.
  3. The text data is searched for occurrences of that word.
  4. Words appearing immediately after it are collected.
  5. The most frequent following word is returned as the prediction.

Shiny Application

The application provides:

  • A text box for entering a phrase
  • A prediction button
  • The predicted next word

Example:

Input: I want to

Prediction: the

The application is deployed using shinyapps.io.

Conclusion

This project demonstrates a simple approach to next-word prediction.

The current application uses a lightweight sample of the SwiftKey dataset.

Future improvements could include larger datasets, n-gram models and more advanced language models for better prediction accuracy.