tetrak_translit¶
Detect, transliterate and fold text in scripts that have several romanisations.
Three functions, one each for the three jobs:
detect()says which script a string is in and, where the script has variants, which – for Armenian, the classical (pre-1922, still used in the diaspora) or reformed orthography; for Russian, the spelling before or after the 1918 reform; for Syriac, whether and how the text is vocalised.transliterate()renders a script in a named romanisation scheme and reads the reversible ones back. The schemes are for display.fold()maps any of the above – the script itself, Latin in any of its schemes – onto one canonical index form, so that a search typed one way finds a record written another. The fold is for finding; its output is a key, not a spelling.
Four scripts so far, each a package of tables the engine runs over:
Armenian (tetrak_translit.hy: ALA-LC, ISO 9985 in its 2026
and 1996 editions, BGN/PCGN, Hübschmann-Meillet and the Western
pronunciation spelling),
Georgian (tetrak_translit.ka: ALA-LC, ISO 9984 in its 2026
and 1996 editions, and the national system),
Russian (tetrak_translit.ru: ALA-LC, with the pre-1918
letters, and BGN/PCGN) and
Syriac (tetrak_translit.syr: ALA-LC, and a consonantal fold
for text that is written without vowels).
>>> import tetrak_translit as tt
>>> tt.detect("Երեւան").orthography
'classical'
>>> tt.transliterate("Երևան", "ala_lc")
'Erevan'
>>> tt.transliterate("თბილისი", "national")
'tbilisi'
>>> tt.fold("Yerevan", script="hy") == tt.fold("Երեւան") == tt.fold("Erewan", script="hy")
True
>>> tt.fold("Chavchavadze", script="ka") == tt.fold("ჭავჭავაძე")
True
No runtime dependencies. Built for a catalogue search and for Tetrak’s own OCR output, where a romanisation beside a transcript is both a catalogue-ready field and an accessibility one.
Functions
|
The available romanisation schemes, for one script or for all. |
|
The registered scripts, in documentation order. |
Modules
Command-line interface: |
|
|
Detect the script of text and, for a registered script, its variant. |
The transliteration engine: pure functions over a |
|
|
Fold text onto its canonical index form. |
Armenian: the script, its six romanisation schemes, orthography and fold. |
|
Georgian: the script, its romanisation schemes and the fold. |
|
Shared pieces of the Latin side of a fold. |
|
The scripts this package handles, and how to find the one a string is in. |
|
Russian: the script, its romanisation schemes, orthography and fold. |
|
The two kinds of data everything else runs over: a script and a scheme. |
|
Syriac: the script, its romanisation, vocalisation and a consonantal fold. |
|
|
Transliterate text between a script and scheme. |