Africa Bitext Builder
Africa Bitext Builder is a Python library for discovering, inspecting, and compiling sentence-aligned parallel and monolingual text corpora across 690+ African languages.
Quickstart
1. Discover Languages & Check Public Domain Status
Use the LanguageRegistry class to inspect supported languages, available translations, and their licensing status:
from africa_bitext_builder.registry import LanguageRegistry
reg = LanguageRegistry()
# Check if a language is supported by its ISO-639 code
swh = reg.resolve("swh")
print(swh)
# <Language code='swh' name='Swahili' region='African' versions=13 (PD: 0)>
# Inspect Public Domain vs. copyrighted translations
print("Public Domain versions:", [v.id for v in swh.public_domain_versions])
print("All available versions:", [v.id for v in swh.bible_versions])
2. Build a Parallel Corpus
Case A: Public Domain Only (Default)
When the requested languages have verified Public Domain versions available (e.g., Twi ↔ English), simply pass the language codes:
from africa_bitext_builder.builder import CorpusBuilder
builder = CorpusBuilder(
source_lang="twi",
target_lang="en",
limit=5000,
)
# Saves automatically to 'corpora/twi_en_parallel.csv'
out_file = builder.download("corpora/")
print(f"Saved: {out_file}")
Case B: Supplying Non-Public Domain Version IDs (User's Own Risk)
If a language has no Public Domain versions available (such as Swahili), or you require a specific translation, you may explicitly pass version IDs discovered via the registry:
from africa_bitext_builder.builder import CorpusBuilder
# Explicitly selecting Swahili (ID: 1627) and French Louis Segond 1910 (ID: 93 - PD)
builder = CorpusBuilder(
source_lang="swh",
target_lang="fr",
source_version_ids=[1627], # Explicit opt-in
target_version_ids=[93], # French Louis Segond (PD)
limit=1000,
sample=True,
seed=42,
)
# Provide a specific .csv file path or a directory path
out_file = builder.download("data/corpora/swahili_french.csv")
print(f"Saved: {out_file}")
3. Build a Monolingual Corpus
Extract deduplicated sentences for a single language:
from africa_bitext_builder.builder import CorpusBuilder
builder = CorpusBuilder(
source_lang="amh",
source_version_ids=[206], # Explicit version opt-in
mode="monolingual",
limit=5000,
)
out_file = builder.download("corpora/amharic.csv")
Data Source & Acknowledgements
- Primary Source: Bible verse texts are retrieved from YouVersion.
- Attribution: This work builds on the pioneering corpus collection effort by Mic-Seth Owusu (AfriSpeech/africa-corpus-builder), and is inspired by the Ghana NLP Community.
- License: Code in this repository is licensed under the MIT License.
⚠️ Licensing & Safety Notice
By default, this library restricts corpus construction exclusively to verified Public Domain (PD) and Creative Commons translations.
- If a language has no Public Domain translations indexed,
CorpusBuilderwill refuse to run by default, in order to prevent unintentional copyright infringement. - Bible version IDs (
source_version_idsortarget_version_ids) may be explicitly specified using metadata retrieved viaLanguageRegistry. - Important Notice on Copyrighted Versions: Supplying version IDs that are not in the public domain is done entirely at your own risk. You are solely responsible for obtaining any necessary permissions or licenses from the relevant copyright holders. The maintainers assume no legal responsibility or liability for the extraction, use, or redistribution of copyrighted translations.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file africa_bitext_builder-0.1.13.tar.gz.
File metadata
- Download URL: africa_bitext_builder-0.1.13.tar.gz
- Upload date:
- Size: 435.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3ce7b4bbb1e767db03952eee5f78dd335b79941cf574120b62371c30e7d24cb
|
|
| MD5 |
295443d08f39f36a70125dcd2578fd09
|
|
| BLAKE2b-256 |
33995d4e285560ca9c9ada6edf2a9837590a4fd4a20932022c4820ab49c7ac98
|
File details
Details for the file africa_bitext_builder-0.1.13-py3-none-any.whl.
File metadata
- Download URL: africa_bitext_builder-0.1.13-py3-none-any.whl
- Upload date:
- Size: 118.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f05072798e8354a409911cc9a5aa291b8530ddc592eb7c88ea0ba69d05b8126e
|
|
| MD5 |
1d84816204a0e868ab218d1b3557416a
|
|
| BLAKE2b-256 |
6c4d5649c0bb52dad43251eed3832766f887fb5ab29c638d679c4aaf377fe6da
|