๐ฏ Project Overview
LangDetect is a Flask-based web application that detects the language of any input text using machine learning. The app uses a trained Multinomial Naรฏve Bayes model to deliver instant predictions with 98% accuracy across 17 supported languages, and is deployed on Railway for seamless access.
Users paste or type any text into the input field, hit Predict, and the model identifies the language in real time โ along with a confidence score. If the input falls outside the 17 supported languages, the app returns a custom "Unable to detect language" message rather than a wrong guess.
โจ Features
- Real-time language detection โ Multinomial Naรฏve Bayes model identifies the language instantly from any text input.
- 98% accuracy โ trained and evaluated on a Kaggle dataset covering 17 languages.
- Confidence score โ displays how certain the model is about its prediction alongside the result.
- Unsupported language handling โ shows a custom "Unable to detect language" message for inputs outside the 17 supported languages.
- Flag-based language display โ all 17 supported languages are shown with their country flags for a visual, user-friendly experience.
- Graceful error handling โ descriptive error pages guide users when invalid or empty input is submitted.
- Cloud deployment โ hosted on Railway for always-on access.
๐ Supported Languages
๐บ๐ธ English ๐ซ๐ท French ๐ช๐ธ Spanish
Western European languages with the broadest global reach.
๐ต๐น Portuguese ๐ฎ๐น Italian ๐ฉ๐ช German
Romance and Germanic language family representatives.
๐ท๐บ Russian ๐ธ๐ช Swedish ๐ณ๐ฑ Dutch
Northern and Eastern European languages.
๐ธ๐ฆ Arabic ๐น๐ท Turkish ๐ฌ๐ท Greek
Middle Eastern and Mediterranean language coverage.
๐ฎ๐ณ Hindi ๐ฎ๐ณ Tamil ๐ฎ๐ณ Malayalam ๐ฎ๐ณ Kannada
Major Indian subcontinent languages across multiple language families.
๐ฉ๐ฐ Danish
Scandinavian language rounding out the 17-language coverage.
๐ผ๏ธ App Preview
Home Page โ Detection Interface
Text input area with a Predict button and a full grid of 17 supported languages shown with flag icons.
Prediction Page โ Result Display
Shows the detected language and confidence score. Displays a custom message for unsupported languages.
Non listed Page โ Result Display
Shows the non-listed language result and custom message showing.
Error Page โ Validation Feedback
Descriptive error messages for empty or invalid inputs, with a visual illustration for better UX.
๐ ๏ธ Technologies Used
- Python โ core programming language for the app and ML pipeline.
- Flask โ lightweight web framework handling routing, templates, and request processing.
- Scikit-learn โ Multinomial Naรฏve Bayes model for language detection, trained on a Kaggle dataset.
- Docker & Docker Compose โ containerization for consistent local and production environments.
- HTML / CSS / JavaScript โ frontend templates and styling for all app pages.
- Railway โ cloud platform for automated deployment and hosting.
โ Input Validation Rules
- Text Input โ cannot be empty or whitespace only.
- Text Length โ must be at least 3 characters for reliable detection.
- Unsupported Language โ if the detected language is outside the 17 supported ones, a custom "Unable to detect language" message is displayed.
- Confidence Level โ the model's confidence percentage is reported alongside every prediction.
๐ Example Workflow
Sample Input
- Text: "Bonjour, comment รงa va?"
Possible Outputs
- Detected: "French ๐ซ๐ท โ Confidence: 99.2%"
- Unsupported: "Unable to detect language. Please enter text in one of the 17 supported languages."
โ๏ธ Installation Guide
Local Setup
- Step 1 โ Clone the repository:
git clone https://github.com/msjahid/langdetect-app.git - Step 2 โ Create a virtual environment:
python -m venv venvthen activate it. - Step 3 โ Install dependencies:
pip install -r requirements.txt - Step 4 โ Run the app:
python app.py - Step 5 โ Open in browser:
http://127.0.0.1:5000/
Docker Setup
- Step 1 โ Build the image:
docker-compose build - Step 2 โ Start the container:
docker-compose up - Step 3 โ Open in browser:
http://127.0.0.1:4000
Deploy on Railway
- Step 1 โ Sign up or log in at railway.app.
- Step 2 โ Create a new project โ Deploy from GitHub repo.
- Step 3 โ Railway auto-detects the Procfile and runtime.txt.
- Step 4 โ Wait for the build and deployment to complete.
- Step 5 โ Access your app at the Railway-provided unique URL.