NLP-based machine learning project for detecting English, French, and Darija text.
# English-French-Darija Language Detection using NLP
This project is a Natural Language Processing and Machine Learning project that detects whether a given text is written in **English**, **French**, or **Darija**.
The model uses character-level TF-IDF vectorization and supervised classification algorithms to learn language-specific text patterns. A simple command-line application is also included, allowing users to enter a sentence and receive the predicted language.
---
## Project Overview
Language detection is an important NLP task used in multilingual applications such as chatbots, search engines, translation systems, customer support platforms, and social media analysis tools.
In this project, text data is preprocessed and transformed into numerical features using **TF-IDF vectorization**. Then, machine learning models are trained to classify each text sample into one of three languages:
- English
- French
- Darija
The final model (Logistic Regression) achieved **98.67% accuracy** on the test set.
---
## Dataset
The dataset contains labeled text samples for three languages.
### Dataset Summary
| Feature | Description |
|---|---|
| Number of rows | 13,153 |
| Number of columns | 2 |
| Input column | Text |
| Target column | Language |
| Languages | English, French, Darija |
| Missing values | None |
### Language Distribution
The dataset is relatively balanced across the three classes:
| Language | Number of Samples |
|---|---:|
| French | 4,530 |
| Darija | 4,384 |
| English | 4,239 |
---
## Project Workflow
The project follows a complete machine learning pipeline:
1. Load and inspect the dataset
2. Check missing values and class distribution
3. Clean text data
4. Split data into training and testing sets (80/20, stratified)
5. Convert text into numerical features using TF-IDF
6. Train machine learning models
7. Compare model performance
8. Evaluate the best model using classification metrics
9. Visualize results using a confusion matr …