Skip to content

yasharth2004/Smart-Text-Composer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

LSTM Text Prediction App ๐Ÿš€

A modern, real-time text prediction application powered by LSTM neural networks. Features a sleek UI with instant word suggestions as you type, similar to modern text editors and IDEs.

Demo Python TensorFlow JavaScript

โœจ Features

  • Real-time Predictions: LSTM-powered word predictions as you type
  • Modern UI: Glassmorphic design with smooth animations
  • Instant Suggestions: Tab to accept, Esc to dismiss
  • Live Statistics: Real-time word and character counts
  • Smart Cursor: Maintains cursor position after predictions
  • Server Status: Visual connection indicator
  • Copy to Clipboard: One-click text copying
  • Responsive Design: Works on desktop and mobile

๐Ÿ› ๏ธ Tech Stack

Backend

  • Python 3.9+
  • Flask - Web framework
  • TensorFlow 2.19.0 - LSTM model
  • Flask-CORS - Cross-origin requests

Frontend

  • HTML5 - Semantic markup
  • CSS3 - Modern styling with glassmorphism
  • Vanilla JavaScript - Real-time interactions
  • REST API - Backend communication

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.9 or higher
  • Node.js (for development server, optional)
  • Modern web browser

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/lstm-text-predictor.git
    cd lstm-text-predictor
  2. Set up the backend

    cd backend
    pip install -r requirements.txt
  3. Start the Flask server

    python app.py

    Server will run on http://localhost:5000

  4. Launch the frontend

    cd ../frontend
    # Open index.html in your browser or use a local server
    python -m http.server 8080

    Frontend available at http://localhost:8080

๐Ÿ“ Project Structure

lstm-text-predictor/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ app.py              # Flask API server
โ”‚   โ”œโ”€โ”€ model.py            # LSTM model definition
โ”‚   โ”œโ”€โ”€ train.py            # Model training script
โ”‚   โ”œโ”€โ”€ requirements.txt    # Python dependencies
โ”‚   โ””โ”€โ”€ models/             # Saved model files
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ index.html          # Main HTML file
โ”‚   โ”œโ”€โ”€ style.css           # Styling and animations
โ”‚   โ”œโ”€โ”€ script.js           # JavaScript functionality
โ”‚   โ””โ”€โ”€ assets/             # Static assets
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ training_data.txt   # Text corpus for training
โ””โ”€โ”€ README.md

๐ŸŽฏ Usage

  1. Start typing in the text editor
  2. View predictions in the suggestions panel
  3. Press Tab to accept the first suggestion
  4. Press Esc to clear suggestions
  5. Click suggestions to insert them directly
  6. Use keyboard shortcuts for efficient editing

Keyboard Shortcuts

Shortcut Action
Tab Accept first prediction
Esc Clear predictions
Ctrl + Enter New line
Arrow Keys Navigate suggestions

๐Ÿ”ง API Endpoints

GET /health

Check server status

{
  "status": "healthy",
  "model_loaded": true
}

POST /predict

Get word predictions

// Request
{
  "text": "The quick brown",
  "max_predictions": 5
}

// Response
{
  "predictions": ["fox", "dog", "cat", "bird", "rabbit"]
}

๐ŸŽจ Customization

Styling

  • Modify frontend/style.css for visual changes
  • Glassmorphic design with CSS backdrop-filter
  • Responsive grid layout

Model Parameters

  • Adjust LSTM layers in backend/model.py
  • Modify sequence length for different contexts
  • Change vocabulary size for domain-specific text

Prediction Logic

  • Edit backend/app.py for custom prediction algorithms
  • Implement confidence scoring
  • Add text preprocessing steps

๐Ÿ› Troubleshooting

Common Issues

Server Connection Failed

# Check if Flask server is running
curl http://localhost:5000/health

Model Loading Error

# Verify TensorFlow installation
python -c "import tensorflow as tf; print(tf.__version__)"

CORS Issues

# Ensure flask-cors is installed
pip install flask-cors

๐Ÿšง Development

Running in Development Mode

# Backend with auto-reload
export FLASK_ENV=development
python app.py

# Frontend with live reload (optional)
npm install -g live-server
live-server frontend/

Testing

# Test API endpoints
python -m pytest tests/

# Frontend testing in browser console
window.textPredictor.checkServerStatus()

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 for Python code
  • Use ES6+ JavaScript features
  • Add comments for complex logic
  • Test on multiple browsers
  • Ensure responsive design

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • TensorFlow team for the amazing ML framework
  • Flask community for the lightweight web framework
  • Open source datasets for training data
  • Modern web standards for glassmorphic design inspiration

๐Ÿ“Š Performance

  • Prediction Speed: < 100ms average response time
  • Model Size: ~50MB (optimized for web deployment)
  • Memory Usage: ~200MB during inference
  • Browser Support: Chrome 90+, Firefox 88+, Safari 14+

๐Ÿ”ฎ Future Enhancements

  • Multi-language support
  • Context-aware predictions
  • User personalization
  • Voice input integration
  • Mobile app version
  • Cloud deployment ready
  • Real-time collaboration

โญ Star this repo if you find it helpful!

About

Modern LSTM-powered text prediction app with real-time suggestions. Features glassmorphic UI, instant word completion, and TensorFlow backend. Type and press Tab to accept predictions!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors