End-to-end NLP pipeline for identifying English, Swahili, Kikuyu, and Sheng.
# π Language Identification System
**Author:** Nelson Ruthari Kariuki (24S01ACS002)
**Course:** CSC423: Special Topics (NLP Term Project)
## π Project Overview
This project is an end-to-end Natural Language Processing (NLP) pipeline designed to identify the language of short text inputs (1-2 sentences). It specifically targets a mix of high-resource, low-resource, and zero-resource African languages: **English, Swahili, Kikuyu, and Sheng** (Kenyan street slang).
## β¨ Key Features
* **Hybrid Data Collection:** Combines Hugging Face open-source datasets (English/Swahili), custom web scraping via Wikipedia (Kikuyu), and combinatorial synthetic data generation (Sheng).
* **Custom Slang Handling:** Utilizes RegEx to preserve unique morphological structures in hyphenated Sheng tokens prior to standard punctuation removal.
* **Character N-Gram Extraction:** Employs Scikit-Learn's `TfidfVectorizer` (2 to 4 character n-grams) to capture the underlying linguistic "DNA" rather than relying on strict word-level vocabularies.
* **Code-Mixing Analysis:** Powered by a Logistic Regression classifier capable of outputting exact probability distributions to handle code-mixed sentences (e.g., English/Swahili blending).
* **Interactive UI:** Fully deployed as a responsive web application using Streamlit.
## π Repository Structure
```text
βββ data/
β βββ cleaned_master_dataset.csv # Final preprocessed and balanced dataset (2000 rows) ready for ML
β βββ english_swahili_data.csv # Raw subset extracted from the Hugging Face NLP corpus
β βββ kikuyu_data.csv # Raw dataset scraped from Kikuyu Wikipedia
β βββ master_language_dataset.csv # The merged but uncleaned compilation of all four languages
β βββ sheng_data.csv # Raw synthetically generated Sheng street slang dataset
βββ models/
β βββ language_model_lr.pkl # Final deployed Logistic Regression model (handles code-mixing)
β βββ language_model_svm.pkl # Archive β¦