📚 PrediText
PrediText is a simple LSTM-based next-word prediction tool. It uses a TensorFlow/Keras LSTM network to learn word sequences and predict the next word in a sentence.
⸻
🚀 Project Structure
PrediText/ ├── data/ │ └── trainingdata.txt # Your text corpus ├── keras_next_word_model.h5 # Saved trained model ├── next_word_pred.py # Main training & prediction script ├── test_env.py. # Quick check for Python & packages ├── requirements.txt # Pip dependencies ├── README.md # Project documentation └── .vscode/ └── settings.json # (Optional) VS Code Python config
⸻
✅ Requirements
This project uses: • Python 3.10+ • numpy • matplotlib • nltk • tensorflow • keras
All dependencies are listed in requirements.txt.
⸻
⚙️ Setup
1️⃣ Create & activate a virtual environment
With Conda (recommended):
conda create -n preditext python=3.10 conda activate preditext
Or with venv:
python3 -m venv venv source venv/bin/activate
⸻
2️⃣ Install dependencies
pip install -r requirements.txt
⸻
🧪 Test your environment
Run:
python test_env.py
✅ This checks: • Python version • numpy, matplotlib, nltk, tensorflow, keras • Downloads punkt for NLTK tokenization
⸻
📚 Train the model
Edit data/trainingdata.txt with your own training text. Run:
python next_word_pred.py
This will: • Load & tokenize your text • Build the LSTM model • Train it • Save it as keras_next_word_model.h5 • Plot training accuracy & loss • Predict next words for test sentences
⸻
✨ Example output
Input: 'The quick brown fox jumps' Predicted next words:
- over (confidence: 0.2345)
- around (confidence: 0.1034)
- through (confidence: 0.0987)
⸻
📝 Notes
✅ This project is for demonstration & learning. ✅ For better results, use a larger training corpus and experiment with embeddings & improved sampling.
⸻
📧 Author
Rakshith KK Built with 💡, Python, and a lot of patience
Happy predicting! 🚀✨