Tetrak
GitHub ↗
Open source

Transliteration and cross-script search

A small library that tells you which script a text is in, writes it in Latin letters by a named library standard, and reduces every spelling of a name to one form, so that one search finds them all.

What it is for

A library catalogue with Armenian, Georgian, Russian or Syriac material records the same name several ways: in its own script, and in two or five Latin spellings depending on who catalogued it and which standard they followed. Armenia’s national poet is Tumanyan, Tumanean, Toumanyan and Tumanian on four book covers, and all four are correct. No stock search engine treats them as one word, so a reader who types one spelling misses the records filed under the others.

tetrak-translit solves that in two directions. For readers, it writes a name in Latin letters exactly as a library standard prescribes. For search, it folds every spelling, Latin or script, to one key, so that an index built with it finds a record however the name was typed.

Who it is for

Catalogue and discovery systems that hold material in these scripts (Koha, Solr and Elasticsearch analysis chains, aggregators); digitisation projects that want a romanised field beside the original; and anyone who has to convert between a script and its romanisations without guessing. It is a dependency-free Python library with a command-line tool, so it fits into a pipeline or a spreadsheet job as easily as into a search engine.

What it does today

Three jobs, in plain words:

  1. Detection. Which script a string is in, and some things about how it is written: for Armenian, whether it uses the classical spelling (printed before the 1922 reform, and still used in the diaspora) or the reformed one; for Russian, whether it is pre-1918 spelling; for Syriac, whether it carries vowel points.
  2. Transliteration, between a script and its named Latin schemes. Each scheme is a tested table written from its published standard, and the library says which ones can be reversed exactly and refuses to guess at the ones that cannot.
  3. The fold. One function that maps any spelling, in the script or in any scheme, to a single search key, so that the index and the query agree. The key is deliberately coarse and never shown to a reader.
ScriptSchemes
ArmenianALA-LC; ISO 9985 (the 2026 edition, and the 1996 one for older data); BGN/PCGN; Hübschmann-Meillet; Western Armenian pronunciation
GeorgianALA-LC; ISO 9984 (2026, and 1996); the Georgian national system
RussianALA-LC, including the pre-1918 letters; BGN/PCGN
SyriacALA-LC, rendering vowels only where the text has them

Syriac is the newest and the most limited: the script is normally written without vowels, so the fold works on consonants alone. The article on searching Syriac explains what that buys and what it costs. The current list of schemes, with every letter of every table, is in the documentation.

What it does not do yet

Get it

pip install tetrak-translit
import tetrak_translit as tt

tt.transliterate("Երևան", "ala_lc")       # 'Erevan'
tt.transliterate("Երևան", "bgn_pcgn")     # 'Yerevan'
tt.fold("Yerevan", script="hy") == tt.fold("Երեւան")   # True
Codegithub.com/scattercode/tetrak-translit
Packagetetrak-translit on PyPI
Documentationscattercode.github.io/tetrak-translit
LicenceMIT

Articles about it