Turkic Transliteration
Try it: https://huggingface.co/spaces/AustinWagner/turkic-transliteration-demo
(This repo is the deployment source for that demo. The Space's card lives at
.github/hf-space/README.md; a push to main writes it, app.py and the
pinned requirement onto the Space. This README used to carry a second copy of
that card, which is how the Space came to install a Gradio the package no
longer accepted.)
Deterministic Latin and IPA transliteration for Turkic languages, plus helper utilities for corpus building, tokenizer/LM training, and Russian-token filtering.
The design decision worth noting: languages are discovered dynamically from
rule files in src/turkic_translit/rules/, so adding a language means adding a
.rules file — no code change, and the CLI, the library API (to_ipa/to_latin)
and the web demo all pick it up at once.
Supported languages (verified by the test suite): Azerbaijani, Finnish, Kazakh, Kyrgyz, Turkish, Uyghur, and Uzbek (both Cyrillic and Latin input). IPA output is available for all of them; Latin output covers Kazakh and Kyrgyz (Cyrillic → Latin, with optional embedded Arabic-script handling) and Turkish (diacritic folding to ASCII).
Install
Python 3.10–3.14, whichever platform: pyicu-wheels publishes the ICU
extension for all of them.
pip install turkic-translit
turkic-translit web # or any of the commands below
The PyPI release can lag the rules on main. A rule fix reaches PyPI
only with the next release, and a corpus transliterated with an older
release carries the older rules; 0.5.9, for example, still writes Kazakh,
Kyrgyz and Cyrillic Uzbek ‹щ› as ɕː, which main corrected to ʃː. To
build a corpus with the current rules, install from the repository:
pip install "git+https://github.com/wagner-austin/turkic_transliteration.git"
The install brings PyTorch with it (for the language-model commands), so expect several gigabytes.
Nothing else: ICU arrives with it. That was not true before 0.5.6 — PyICU
publishes no wheels on any platform, so an install had to compile against ICU
headers, and this project shipped a Windows wheel fetcher to work around it.
The dependency is pyicu-wheels, which publishes the same extension prebuilt
for Linux, macOS and Windows.
To work on the project rather than use it:
git clone https://github.com/wagner-austin/turkic_transliteration.git
cd turkic_transliteration
pip install -e .[dev] # or: python scripts/setup_dev.py
turkic-translit web
Optional extras: dev (ruff, mypy, pytest) · examples (Flask, Streamlit,
JupyterLab) · sentry (error reporting).
Package names
- Import path:
turkic_translit - PyPI distributable:
turkic-translit - Primary CLI entry point:
turkic-translit
Development
The Makefile wraps the common tasks (all via Poetry):
make check # lint + test (the full gate)
make lint # guards, then ruff check + ruff format --check, then strict mypy; writes nothing
make format # the one target that rewrites: ruff check --fix + ruff format
make guard # just the guard rules (scripts/guards/)
make test # pytest with 100% statement+branch coverage enforced
make web # launch the Gradio web UI
Linting, type-checking (strict mypy) and the guard rules all cover src,
tests and scripts. The guards ban weak typing (Any, casts, ignores),
silent exception handling, and weak or fake tests — including
transliteration tests that never compare output against an expected value.
They also hold every Python file to 600 lines, and fail on any tracked file
that is a Windows shell script or tells a reader to use Windows tooling;
the changelog alone may name what was removed.
Validation
- Every IPA rule file declares its source in machine-readable
# Source-*header fields, and a test module that pins expected output must name the source it inherits (INHERITS_SOURCE); both are guard-enforced, as is the ban on expectations computed by the code under test. - Expected values are transcriptions printed in the cited descriptions (journal Illustrations, reference-grammar chapters). Each language is covered letter-exhaustively plus word sets from a second, independent description; Uyghur is additionally checked against the MFA dictionary's 22,630 pronunciations.
- Departures from a source's printed notation are declared in two tables —
NOTATION(different glyph, same phoneme) andDECLARED_SIMPLIFICATIONS(a real distinction the rules drop) — each entry carrying a reason. A central test fails any entry no printed datum exercises, and a cross-language test requires shared letters to agree across languages after corpus harmonization unless a contrast is declared with a citation.
Command-line tools
Console entry points defined in pyproject.toml:
| Command | Purpose |
|---|---|
turkic-translit |
Transliterate text to Latin and/or IPA |
turkic-translit web |
Launch the Gradio web demo |
turkic-filter-russian |
Drop or mask Russian tokens from a stream |
turkic-download-corpus |
Download/prepare OSCAR corpora |
turkic-clean-corpus |
Clean and harmonize downloaded corpora |
turkic-build-spm / turkic-train-spm |
Train a SentencePiece tokenizer |
turkic-train-lm / turkic-eval-lm |
Train / evaluate a language model |
turkic-leven |
Levenshtein-based comparison utility |
turkic-translit translit usage
turkic-translit translit --lang kk --in text.txt \
--out-latin kk_lat.txt --out-ipa kk_ipa.txt --arabic
--lang— any code advertised by the rules directory; IPA is available foraz,fi,kk,ky,tr,ug,uzanduzc(Uzbek Cyrillic)--in— input file, or-for stdin (default:-)--out-latin— Latin output path, or-for stdout. Omit to skip. Only meaningful for languages with<lang>_lat.rules(kk,ky,tr).--out-ipa— IPA output path, or-for stdout. Omit to skip.--arabic— also transliterate embedded Arabic script (Latin mode only)--benchmark— log throughput statistics on completion
At least one of --out-latin / --out-ipa must be specified.
--log-level is set on the parent group: turkic-translit --log-level debug translit ....
turkic-download-corpus usage
export HF_TOKEN=... # OSCAR-2301 is gated on Hugging Face
turkic-download-corpus download --source oscar-2301 --lang kk --out kk.txt \
--max-lines 125000 --filter-langid kaz --lid-model lid218e --lid-threshold 0.95
--langis the source's code (ISO 639-1,kk);--filter-langidis the classifier's label, matched as a prefix. lid.176 labels Kazakhkk, but lid218e labels itkaz_Cyrl, so under lid218e passkaz. A code the model never reports is refused before streaming, naming the label to use instead, and a filter that keeps no line ends in an error rather than an empty file.- The manifest beside the output records the source, the classifier's weights and threshold, and the SHA-256 of the file written.
turkic-clean-corpus usage
The rules transliterate their own script and pass everything else through unchanged, so English, URLs and code quoted in web text reach the IPA file in their original spelling. The cleaner removes them: each language's set of emittable characters is derived from its own rules, and a token carrying any letter outside that set is dropped whole.
mkdir -p raw # translit writes into an existing directory; it does not create one
turkic-translit translit --lang kk --in kk.txt --out-ipa raw/kk_ipa.txt
turkic-clean-corpus --input-dir raw --output-dir clean
- The cleaner takes only IPA the installed rules wrote.
translit --out-ipa <file>writes<file>.manifest.jsonbeside the IPA, naming the rule file, its digest and the IPA's SHA-256, and the cleaner refuses a corpus with no such record, one naming other rules, or one whose bytes changed since. IPA from an older release spells some letters differently (‹я› asjabefore 0.5.7, ‹щ› asɕːbefore 0.5.10), and cleaning it against the current rules would drop those words as foreign, so transliterate the source text again instead. --input-dir/--output-dir— raw IPA corpora in, cleaned corpora andcleaning_manifest.jsonout. The language is read from each file name (kk_ipa.txt,oscar_kk_ipa.txt), which must carry exactly one two-letter code.- The stages run in this order: the symbol map harmonises notation across
languages; lines whose share of transcription characters is below
--min-ipa-ratio(default 0.95) are dropped; foreign tokens are dropped; punctuation, digits and other characters the rules cannot emit become spaces; lines shorter than--min-line-chars(default 30) are dropped; repeated lines are dropped, keeping the first. The order and the reason for each stage are inturkic_translit/corpus/clean.py. - Last, every corpus in one run is cut to the size of the smallest, so a cross-language comparison measures languages rather than data volume. Clean one language on its own to keep all of it.
- The manifest counts every drop and replacement, and fingerprints the rule files and symbol map the run used.
- Clean only text transliterated by the same version of the rules: the emittable set comes from the installed rules, so a corpus made under older rules can carry letters the current ones no longer emit, and the cleaner drops those tokens as foreign.
Tokenizer training
turkic-build-spm --input corpora/kk_lat.txt,corpora/ky_lat.txt \
--model_prefix spm/turkic12k --vocab_size 12000
Filtering Russian tokens
cat uz_raw.txt | turkic-filter-russian --mode drop > uz_clean.txt
Project Organization
src/turkic_translit/— core package (core.py,transliterate.py,rules/,cli/,web/,lm/, language-ID and filtering modules)data/— sample data and language resourcesdocs/— documentation and guidesscripts/— development utilities (setup_dev.py, the guard rules, the Hugging Face Space sync); releasing is a push tomaintests/— test suite (per-language IPA coverage for all supported languages)cronjob/— scheduled-task assets for the hosted demoapp.py— Hugging Face Space entry point for the web UI
FastText language-identification model
Russian-token filtering and language detection use FastText's lid.176.bin,
and corpus filtering can use NLLB's lid218e.bin. Neither is committed (too
large). Each is downloaded on first use from this project's Hugging Face mirror,
AustinWagner/turkic-translit-lid,
and cached in the package directory, so pip installs, the Hugging Face Space and
CI need no manual step. The mirror holds Meta's files byte for byte: the
registry (src/turkic_translit/lid/registry.py) pins the SHA-256 of each, and a
download with any other digest is deleted and refused
(TURKIC_LID_011_MODEL_DIGEST_MISMATCH). Meta's originals, which the
mirror-lid-models workflow copies from:
https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin and
https://dl.fbaipublicfiles.com/nllb/lid/lid218e.bin
Logging & error reporting
Central logging supports structured JSON with correlation IDs. Control with
TURKIC_LOG_LEVEL (DEBUG…ERROR) and TURKIC_LOG_FORMAT=json|rich (default
json); libraries can call turkic_translit.logging_config.setup(). Optional
Sentry integration via TURKIC_SENTRY_DSN (+ TURKIC_ENV,
TURKIC_SENTRY_TRACES); install with pip install turkic-translit[sentry].
All I/O is UTF-8, with no byte-order mark, on every platform.
Relationship to the LSTM project
This repo is the upstream data pipeline for the Turkic mutual-intelligibility
LSTM experiments (github.com/wagner-austin/LSTM): turkic-download-corpus plus
the IPA transliteration rules produce the per-language IPA corpora that project
trains on.
License
Apache-2.0
Metadata
Release files for turkic-translit 0.5.13
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 |
|---|---|---|---|---|
| turkic_translit-0.5.13.tar.gz | 341.1 kB | With provenance | Details for turkic_translit-0.5.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| turkic_translit-0.5.13-py3-none-any.whl | Python 3 | none | any | Details for turkic_translit-0.5.13-py3-none-any.whl |
Total release size: 538.1 kB
Release files / turkic_translit-0.5.13.tar.gz
| Download URL | turkic_translit-0.5.13.tar.gz |
|---|---|
| Size | 341.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0178e196003e1dedb8652de75e7dc95ac7cc47b4c6b9b3589d90709fa1ee7f5
|
|
BLAKE2b-256 checksum How to use checksums |
079013406769e0068eb1adecc5dc6356078683cba78c2195d19319f3abc6f56f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logRelease files / turkic_translit-0.5.13-py3-none-any.whl
| Download URL | turkic_translit-0.5.13-py3-none-any.whl |
|---|---|
| Size | 197.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7bd148ed050e23438e166509588b7345dcb84b1504395761d6dd4885543e0017
|
|
BLAKE2b-256 checksum How to use checksums |
c857f3645ec9c04a0aa67dee9929051a83b8b719a2d22f2dc9aaf41014a7b203
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logSecurity for turkic-translit 0.5.13
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for turkic_translit-0.5.13.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logA 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.