Low-Resource NLP Toolkit
Python tools for preparing and evaluating multilingual text, with an initial focus on African languages. The package covers Unicode-aware normalisation, lightweight language routing, code-switch audits, emotion-label mapping and classification metrics.
Current release: 0.3.0.
What it covers
- Text normalisation that preserves diacritics by default.
- Lexical routing for Yoruba, Igbo, Hausa, Nigerian Pidgin, Swahili and English.
- Selective routing, so weak decisions can be rejected instead of forced into a language.
- Token-level code-switch audits with evidence spans and character offsets.
- Emotion-label harmonisation across categorical and valence-arousal formats.
- Classification, confusion-matrix and coverage-aware evaluation.
- A command-line interface with no model download or API key requirement.
Measured benchmark
The router has been evaluated on the official AfriSenti development and test splits for Hausa, Igbo, Nigerian Pidgin, Swahili and Yoruba. The source revision and file hashes are pinned, and the source tweets remain outside this repository.
On 18,402 held-out test tweets, ordinary corpus-language routing accuracy was 74.75%. A rejection threshold chosen on development data reached 89.65% accuracy on the accepted test items at 74.03% coverage.
A paired stress test also measured the effect of removing diacritics. Overall accuracy fell from 74.75% to 69.87%; the largest changes were for Yoruba, down 15.17 percentage points, and Igbo, down 5.95 points. This is why the normaliser preserves diacritics unless removal is requested explicitly.
See the full benchmark report for the method, per-language results, confidence intervals and limitations.
Installation
python3 -m venv .venv
source .venv/bin/activate
python -m pip install low-resource-nlp-toolkit
low-resource-nlp --version
Route a text sample:
low-resource-nlp route "abeg make una help me check this model output"
Reject routes with a narrow score margin:
low-resource-nlp route "check" --min-score-margin 0.75
Audit code-switched language evidence:
low-resource-nlp audit "abeg make una check this model output"
Normalise text:
low-resource-nlp normalise "Ẹ káàrọ̀!!! Visit https://example.com @user"
Map an emotion label:
low-resource-nlp label joy
Python API
from low_resource_nlp import (
LexicalLanguageRouter,
audit_code_switching,
label_to_valence_arousal,
normalise_text,
)
text = normalise_text("Ẹ káàrọ̀, báwo ni?")
router = LexicalLanguageRouter.default()
route = router.route_selectively(text, min_score_margin=0.75)
audit = audit_code_switching("abeg make una check this model output")
emotion = label_to_valence_arousal("joy")
print(route.accepted_language_code, route.score_margin)
print(audit.language_mix, audit.warnings)
print(emotion)
Reproducing the benchmark
git clone https://github.com/oyinkanchekwas/low-resource-nlp-toolkit.git
cd low-resource-nlp-toolkit
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .
make benchmark
The command downloads the ten pinned AfriSenti files, verifies their SHA-256 hashes, selects the rejection policy on development data and writes aggregate test results. It does not copy source tweets into the report.
Run the local checks with:
make check
Limitations
The router uses small, inspectable lexical profiles. It is useful for corpus checks, teaching and reproducible baselines, but it is not a substitute for a trained language-identification model or native-speaker review. AfriSenti provides corpus-level language labels and includes code-mixed text, so an apparent routing error is not always an incorrect word-level decision.
Language and emotion predictions must not be treated as identity labels, clinical assessments or ground truth about a person.
Links
Metadata
Release files for low-resource-nlp-toolkit 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| low_resource_nlp_toolkit-0.3.0.tar.gz | 21.5 kB | Without provenance | Details for low_resource_nlp_toolkit-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| low_resource_nlp_toolkit-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for low_resource_nlp_toolkit-0.3.0-py3-none-any.whl |
Total release size: 40.2 kB
Release files / low_resource_nlp_toolkit-0.3.0.tar.gz
| Download URL | low_resource_nlp_toolkit-0.3.0.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a77295bb2fd56423e25161088313e72f8442b684e686dc980200a32fda9cd84
|
|
BLAKE2b-256 checksum How to use checksums |
0bd9f5f176f5406deaf957fe77e0e073eca861c2a1ccbd71b53a3e0c9ec48681
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / low_resource_nlp_toolkit-0.3.0-py3-none-any.whl
| Download URL | low_resource_nlp_toolkit-0.3.0-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7cb458aa5cfc446aa6d664bfae4a77907edcd02791f31f7aee986daa168e5887
|
|
BLAKE2b-256 checksum How to use checksums |
71fefeaf47ddeead67543c13ea7ae1fafe3d8b2d22a4ae9c4890e1ee116804ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for low-resource-nlp-toolkit 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.