NLP model to detect and classify Wolof and French text using machine learning
# Wolof-French Language Detection
NLP model to automatically detect whether a text is written in Wolof or French.
## Motivation
Wolof is spoken by over 10 million people in Senegal and the diaspora, yet it
remains one of the most underrepresented languages in NLP research. Most language
detection tools fail completely on Wolof. This project builds a detection model
from scratch using character-level features that capture the unique patterns of
the Wolof language.
## What This Project Does
- Builds a bilingual Wolof/French dataset of 60 phrases from scratch
- Uses character-level TF-IDF features (n-grams 2-4) to capture language patterns
- Trains and compares Naive Bayes and Logistic Regression models
- Achieves 100% accuracy on test set
- Includes a phrase tester that detects language with confidence score
## Results
| Model | Accuracy |
|---|---|
| Naive Bayes | 100% |
| Logistic Regression | 100% |
Both models achieve perfect accuracy. Character-level n-grams are highly effective
at distinguishing Wolof from French due to unique character combinations in Wolof
(ë, à, ñ, etc).
## Key Insight
Wolof contains unique character sequences that do not exist in French, making
character-level n-gram features extremely powerful for this task. The model
detects language in milliseconds with high confidence.
## Tech Stack
- Python 3.14
- Scikit-learn — TF-IDF vectorization, Naive Bayes, Logistic Regression
- Pandas — data manipulation
- Matplotlib — visualizations
## How to Run
1. Clone this repository
2. Install dependencies
```bash
pip install pandas numpy matplotlib seaborn scikit-learn
```
3. Run the notebook `notebooks/wolof_detection.ipynb`
## Dataset
60 phrases manually curated — 30 Wolof, 30 French. Phrases cover everyday
conversations, greetings, and common expressions used in Senegal.