NicoleMathias/grammer-error-correction
0
Multilingual Grammar Error Detection & Correction
A powerful web application for detecting and correcting grammar errors in multiple languages using state-of-the-art AI models.
๐ Supported Languages
- English - Error detection + Grammar correction
- Czech - Error detection only
- German - Error detection only
- Italian - Error detection only
- Swedish - Error detection only
โจ Features
- ๐ Grammar Error Detection: Identifies grammar errors with confidence scores
- โ๏ธ Grammar Correction: Corrects errors (English only)
- ๐ Multilingual Support: 5 languages with specialized models
- ๐จ Modern UI: Clean, responsive web interface
- ๐ง REST API: Full API for integration
- ๐ Detailed Analysis: Error statistics and confidence scores
๐ Quick Start
Local Development
# Clone the repository
git clone <your-repo-url>
cd automatic_grammar_error_correction
# Install dependencies
pip install -r requirements.txt
# Run the application
python app.py
# Open http://localhost:7860Hugging Face Spaces Deployment
See README_HF_SPACES.md for detailed deployment instructions.
๐ง API Endpoints
Example API Usage
# Error Detection
curl -X POST http://localhost:7860/api/detect \
-H "Content-Type: application/json" \
-d '{"text": "I goes to the store", "language_code": "en"}'
# Grammar Correction
curl -X POST http://localhost:7860/api/correct \
-H "Content-Type: application/json" \
-d '{"text": "I goes to the store", "language_code": "en"}'๐ Model Information
- T5 Model: Grammar correction (English only)
- BERT Models: Error detection for each language
- English: FCE dataset
- Czech: GECCC dataset
- German: Falko-Merlin dataset
- Italian: Merlin dataset
- Swedish: SWELL dataset
๐ฏ Language Capabilities
๐ ๏ธ Technology Stack
- Backend: Flask (Python)
- AI Models: Transformers (BERT, T5)
- Frontend: HTML, CSS, JavaScript
- Deployment: Docker, Hugging Face Spaces
- Dependencies: PyTorch, Transformers, NumPy
๐ Project Structure
automatic_grammar_error_correction/
โโโ app.py # Main Flask application
โโโ templates/
โ โโโ multilingual.html # Web interface
โโโ models/ # BERT models for each language
โโโ t5_jfleg/ # T5 model for correction
โโโ requirements.txt # Python dependencies
โโโ Dockerfile # Docker configuration
โโโ README_HF_SPACES.md # Deployment guide๐ Usage Examples
Web Interface
- Select your language from the dropdown
- Enter text to analyze
- Choose an action:
- Detect Errors: Find grammar errors
- Correct Grammar: Fix errors (English only)
- Full Analysis: Both detection and correction
API Response Examples
Error Detection:
{
"accuracy": 0.806,
"avg_confidence": 0.921,
"dataset": "FCE",
"tokens": [
{"token": "I", "tag": "c", "confidence": 0.95},
{"token": "goes", "tag": "i", "confidence": 0.86}
]
}Grammar Correction:
{
"success": true,
"corrected_text": "I go to the store",
"original_text": "I goes to the store"
}๐จ Troubleshooting
Common Issues
- Model Loading: First run may take time to download models
- Memory: Models require significant RAM (~2GB)
- Port Conflicts: App uses port 7860 by default
Health Check
curl http://localhost:7860/api/health๐ Performance
- Error Detection: ~80-85% accuracy across languages
- Grammar Correction: ~90% accuracy for English
- Response Time: 1-3 seconds per request
- Model Size: ~2GB total
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
๐ License
MIT License - see LICENSE file for details
๐ Acknowledgments
- Hugging Face for the Transformers library
- The research teams behind the fine-tuned models
- The open-source community for various tools and libraries
Ready for deployment! ๐
For deployment instructions, see README_HF_SPACES.md.
