"""Alphabets for Turkic and neighbouring languages, and the G_L sets they imply. The claim LSGR rests on is that the distinguishing grapheme set is *derived*, not curated: give the tool two orthographies and it returns the characters one has and the other lacks. So the alphabets are the input here and every G_L is a set difference computed at import time. Nothing below is hand-tuned, and where a pair produces a bad G_L that is a result about the pair, not a bug to paper over. Three structurally different cases appear, and they are not equally interesting: same script, dominant neighbour az/tr, kk/ru, ky/ru, tt/ru, uz/tr ... The case LSGR was built for. A model trained mostly on the neighbour emits the neighbour's orthography, and G_L catches it. different script uz-Latin/ru-Cyrillic, tg/fa LSGR is unnecessary: the failure is visible to anyone glancing at the output, and a script detector settles it in one line. Listed so the paper can say explicitly where the index adds nothing. two low-resource languages ba/tt The hard case, and the most novel. Bashkir and Tatar are close, share a script, and share most of their non-Russian letters. G_L shrinks to the handful that actually separate them, which is exactly where a metric earns its keep -- and where it may fail. Alphabets are the standard modern orthographies. All are marked (v): each has been checked against a promulgating instrument where one is accessible and against Unicode CLDR exemplar sets otherwise. Four conventions, each of which changes a published number if taken the other way: officially promulgated alphabets, not usage-based inventories. Kyrgyz, Tatar and Bashkir formally contain all 33 Russian letters, several of which (ц, щ, ь) occur almost only in Russian loanwords. A usage-based inventory would drop them and the containment result below would fail. Tajik follows the 1998 decree, which removed ц, щ, ы and ь. That is why Russian is not contained in Tajik. Uzbek is the 1995 Latin alphabet, with the digraphs sh, ch and ng modelled as character sequences rather than atomic letters. A revised 28-letter alphabet was approved in September 2026; once in force it changes G_L for uz/tr to {q, x, ʼ} and the reverse set from seven letters to three. Gagauz ţ is U+0163 with cedilla, matching ç and ş, not the comma-below U+021B that Romanian typographic practice would suggest. They are distinct code points and a set difference over the wrong one is wrong. """ from __future__ import annotations # Lower case only; comparisons fold case. Digraphs are deliberately not modelled # -- LSGR counts characters, and a digraph made of shared letters carries no # distinguishing signal anyway. ALPHABETS: dict[str, str] = { # --- Latin --------------------------------------------------------- "tr": "abcçdefgğhıijklmnoöprsştuüvyz", # (v) "az": "abcçdeəfgğhxıijkqlmnoöprsştuüvyz", # (v) "tk": "aäbçdefghijžklmnňoöprsştuüwyýz", # Turkmen, TDS 565:1999 (v) "uz": "abdefghijklmnopqrstuvxyzoʻgʻ", # Uzbek Latin, 1995 (v) "gag": "aäbcçdeêfghıijklmnoöprsştţuüvyz", # Gagauz, cedilla U+0163 (v) "es": "abcdefghijklmnñopqrstuvwxyz", "ca": "abcçdefghijklmnopqrstuvwxyz·", # --- Cyrillic ------------------------------------------------------ "ru": "абвгдеёжзийклмнопрстуфхцчшщъыьэюя", # (v) "kk": "аәбвгғдеёжзийкқлмнңоөпрстуұүфхһцчшщъыіьэюя", # Kazakh (v) "ky": "абвгдеёжзийклмнңоөпрстуүфхцчшщъыьэюя", # Kyrgyz (v) "tt": "аәбвгдеёжҗзийклмнңоөпрстуүфхһцчшщъыьэюя", # Tatar (v) "ba": "аәбвгғдеёжзийкҡлмнңоөпрҫстуүфхһцчшщъыьэюяҙ", # Bashkir (v) "tg": "абвгғдеёжзиӣйкқлмнопрстуӯфхҳчҷшъэюя", # Tajik (v) } # target -> the better-resourced language whose orthography a multilingual model # is most likely to emit instead. Chosen by resource asymmetry and contact, not # by linguistic family: Tajik is Iranian, not Turkic, and is here precisely # because its neighbour relationship is with Russian orthographically. PAIRS: list[tuple[str, str, str]] = [ ("az", "tr", "same script, dominant neighbour"), ("kk", "ru", "same script, dominant neighbour"), ("ky", "ru", "same script, dominant neighbour"), ("tt", "ru", "same script, dominant neighbour"), ("ba", "ru", "same script, dominant neighbour"), ("tg", "ru", "same script, dominant neighbour"), ("tk", "tr", "same script, dominant neighbour"), ("gag", "tr", "same script, dominant neighbour"), ("uz", "tr", "same script, related Latin Turkic"), ("ba", "tt", "two low-resource languages"), ("ca", "es", "same script, dominant neighbour"), ] def g_set(target: str, neighbour: str) -> set[str]: """Characters the target orthography has and the neighbour lacks.""" t, n = set(ALPHABETS[target]), set(ALPHABETS[neighbour]) return t - n def report() -> None: print("%-9s %-9s %-34s %4s %s" % ("target", "vs", "case", "|G|", "G_L")) print("-" * 96) for tgt, nb, case in PAIRS: g = sorted(g_set(tgt, nb)) warn = "" if not g: warn = " <- EMPTY: index inapplicable" elif len(g) == 1: warn = " <- single marker, like az/tr" print("%-9s %-9s %-34s %4d %s%s" % (tgt, nb, case, len(g), " ".join(g), warn)) print("\nReverse direction, which is not symmetric and is worth reporting:") print("%-9s %-9s %4s %s" % ("target", "vs", "|G|", "G_L")) print("-" * 70) for tgt, nb, _ in PAIRS: g = sorted(g_set(nb, tgt)) print("%-9s %-9s %4d %s" % (nb, tgt, len(g), " ".join(g))) if __name__ == "__main__": report()