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.

  • 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.

Two scripts so far, each a package of tables the engine runs over: Armenian (tetrak_translit.hy: ALA-LC, ISO 9985, BGN/PCGN, Hübschmann-Meillet and the Western pronunciation spelling) and Georgian (tetrak_translit.ka: ALA-LC, ISO 9984 and the national system).

>>> 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 the Armenian heritage aggregator described in Tetrak’s brief 015 and for Tetrak’s own OCR output, where a romanisation beside a transcript is both a catalogue-ready field and an accessibility one.

Functions

schemes([script])

The available romanisation schemes, for one script or for all.

scripts()

The registered scripts, in documentation order.

Modules

cli

Command-line interface: tetrak-translit.

detect(text)

Detect the script of text and, for a registered script, its variant.

engine

The transliteration engine: pure functions over a Scheme.

fold(text, *[, script, scheme])

Fold text onto its canonical index form.

hy

Armenian: the script, its five romanisation schemes, orthography and fold.

ka

Georgian: the script, three romanisation schemes and the fold.

latin

Shared pieces of the Latin side of a fold.

registry

The scripts this package handles, and how to find the one a string is in.

script

The two kinds of data everything else runs over: a script and a scheme.

transliterate(text[, scheme, script, to])

Transliterate text between a script and scheme.