The canonical fold¶
fold() maps any spelling of a word — its own script, Latin in any
romanisation — onto one canonical index form, so that a search typed one
way finds a record written another. It is the function a Solr or
Elasticsearch analysis chain calls, at index time and at query time.
>>> import tetrak_translit as tt
>>> {tt.fold(s, script="hy") for s in ["Երևան", "Երեւան", "Erevan", "Erewan", "Yerevan"]}
{'erevan'}
>>> {tt.fold(s, script="ka") for s in ["თბილისი", "Tʻbilisi", "T'bilisi", "Tbilisi"]}
{'tbilisi'}
Finding, not display¶
The key the fold returns is a deliberately coarse Latin skeleton. It merges things a reader would want kept apart because the point is that Hagop and Yakob, or Chavchavadze and Ch’avch’avadze, land in the same place. Never show a fold key to a reader. Index the folded field for search and keep the original for display.
This is also why the fold does not claim there is a single right spelling. Cross-script name-matching research (LREC 2020, cited in Tetrak’s research notes) finds there is often no gold form to score against. The schemes are for display; the fold is for finding; the two are kept apart on purpose.
Each script owns its rules¶
What should be merged differs between scripts, so each script package
carries its own fold and the top-level function only decides which rules
a token gets. A token in a registered script gets that script’s rules. A
Latin token gets the rules of the script named by script=, and raises
if none is named: Armenian folds b with p because Eastern and
Western spellings swap them, Georgian must not because ბ and პ are
different letters that never swap, and Batumi folded under Armenian
rules would never find ბათუმი. Russian keeps them apart too.
Armenian¶
Armenian input loses the intonation marks Armenian sets inside a word, on the stressed vowel (the question, exclamation and emphasis marks
՞ ՜ ՛:ելնելո՞ւfolds asելնելու; left in, the mark splits theու), and is normalised across the 1922 reform, towards the reformed spelling:եւbecomesև;էbecomesե; the classical digraphsեաandիւbecomeյաandյու;եոbecomesեվո(Գէորգ is Gevorg); a word-initialյbefore a vowel becomesհ, as the reform wrote it (ՅակոբisՀակոբ,յետisհետ); and a word-finalյafter a vowel is dropped (ծառայisծառա). It is then rendered through ALA-LC, the 2011 table frozen inside the fold so that a new edition of the display table never moves a key, so that Armenian and ALA-LC Latin reach the next step by the same road.Latin
jis read asձwhen the text shows ISO 9985 or Hübschmann-Meillet. Those two schemes writeձasjandջasǰ; ALA-LC and BGN/PCGN writeջasj. A mark only ISO 9985 or Hübschmann-Meillet makes —č ǰ š ž ġ ł ə ë ç, the Hübschmann-Meillet aspirationʿ,cwith an aspiration mark, or ISOow— anywhere in the text being folded, not only in the same word, turns every barejin it intodz: Jayn hayreneacʿ findsՁայն հայրենեաց. A barecis not counted, because popular spellings use it.Latin is lowercased and stripped of every diacritic and aspiration mark, and an intonation mark inside a word goes, since the schemes render it where it stands (
կարդացե՞լis kardac’e?l) and a hand, or a release before 3.4.0, may set it inside a digraph (elnelo?w). An aspirate written with an h loses it (thandt,phandp, so Thoumanian findsԹումանյան), and an h after v is dropped (vhandv, so Hovannes finds Hovhannes). Then its digraphs are collapsed onto one spelling each (žandzh;xandkh;ł,ġandgh;ow,ou,ooandu;iwandiu, for the classicalիւ;wandv;ivoandio, for the glide Western says in Virkilivos); aywith a consonant beside it and no vowel on either side is read as BGN/PCGN’sըand becomese, the other schemes’ letter for it (zhanry findsժանրը, ynker findsընկեր); the voiced and voiceless pairs are merged (b/p,d/t,g/k,dz/ts/c,j/ch;dbeforets, so that Western’sdsforտս, badsbaran, reachescwith ALA-LC’sts); the glides are regularised (word-initialye,heande,voando, where a hyphen or a bracket also starts a word, as BGN/PCGN and Western count it: Ter-Yeghishe, hay[yeren]; thehebecause a classicalյեis the reform’sհե, which the Armenian side has just made it, while the schemes that writeյasyin every position render the classical spelling ye, so Yeghapʻokhakan, Heghapʻokhakan and Ḥeghapʻokhakan must be one;iu;yandhat the start of a word or after a hyphen, and for the lone initialՅ., so that Ḥ. and H. find it; andhoandofor the Russian-mediated Ovanes and Ovsep;ya,eaandia); ayafteriuat the end of a word is BGN/PCGN’sըand becomese(tʻiwy forթիւը); any otheryafter a vowel is dropped at the end of a word and before a hyphen or a bracket (the silentյof hay-ṛuseren); doubled letters are collapsed; and anything that is not a letter or a digit is removed.
Georgian¶
Georgian input has its archaic letters folded onto their modern values (
ჱ ე,ჲ ი,ჳ ვ,ჴ ხ,ჵ ო) andჶonto thefthat ISO 9984 writes for it, and is rendered through ALA-LC, the 2011 table frozen inside the fold as the Armenian one is.Latin is lowercased and stripped of diacritics and apostrophes, which merges each aspirate with its ejective whichever system marked which; the sibilant spellings are collapsed (
ž/zh,š/sh,č/ch,ǰ/j,ḡ/gh,x/kh);dzandjbecome one,tsandcbecome one;qbecomesk(so Kazbegi findsყაზბეგი);ybecomesiandwbecomesv; doubled letters are collapsed; and anything that is not a letter or a digit is removed.
Russian¶
Cyrillic is rendered through ALA-LC, the 2012 table frozen inside the fold. Because that table covers the letters the 1918 reform removed, pre-reform spelling reaches the Latin side with them already on their modern values:
ѣandеboth become e,іandиboth i,ѳf,ѵy, and the final hard sign is dropped with the other signs.Русскій вѣстникъandРусский вестникshare a key.Latin is lowercased; the scholarly háček letters become the ALA-LC digraphs (
žzh,šsh,čch,ŝshch) and ISO 9’sâandûbecome ia and iu; diacritics, ties (U+0361 and the older U+FE20/U+FE21), signs, apostrophes and BGN/PCGN’s middle dot go. Then, in order:the German and French sibilants collapse: schtsch to shch, tsch and tch to ch, sch to sh, and ou becomes u;
xbecomes ks (Alexei),wbecomes v (Tschaikowski), andjandybecome i;a
cthat does not begin ch isц, as in ISO 9 and the scholarly spelling, and becomes ts, as does tz;an
hthat is not part of zh, kh, ch or sh isх, as in ISO 9 and Mihail, and becomes kh;an i before e goes, because ALA-LC writes the glide nowhere: Yevgeniy, Andreyev and Vasilyev meet Evgeniĭ, Andreev and Vasilʹev;
io after a consonant becomes e, because ALA-LC writes
ёas ë: Fyodor and Pyotr meet Fëdor and Pëtr;a closing ff becomes v (Prokofieff);
doubled letters are collapsed, and anything that is not a letter or a digit is removed. -sky, -skiy, -skij and -skiĭ all end -ski.
Syriac¶
Syriac is written without vowels, and every romanisation supplies its own: ALA-LC from a dictionary (Penqítā), the West Syriac pronunciation with o for ALA-LC’s ā and the soft consonants spelled out (Fenqīthō), the East Syriac one (Ḥūdrā). What they share is the consonants, so the key is the consonants.
Syriac is rendered through ALA-LC’s consonants, frozen inside the fold; vowel points become vowels the next step drops, and the signs (rukkākā, quššāyā, seyāmē) go. The Garshuni and Persian letters fold onto the consonants they write.
Both sides are then lowercased and stripped of diacritics and the half rings, which drops alaph and ʿē.
šand sh are kept apart from s and h, and written c in the key, a letter no other rule leaves behind. The soft consonants spelled out (th ph kh gh dh bh) and the Greek ch become single letters;fbecomes p,candqbecome k. Then every vowel goes, and with themw,y,jandv, which are waw and yod, the letters that also write long vowels: ú andܘmust meet.ḥandhbecome one, as doṭandt,ṣands. Doubled letters are collapsed, and anything that is not a letter or a digit is removed, so ALA-LC’s da-qdām is the script’sܕܩܕܡ.
Penqítā, Fenqīthō, Fenqitho and ܦܢܩܝܬܐ are all pnkt.
Tokens are folded one at a time and joined with single spaces, so a title folds to a sequence of keys that a whitespace tokeniser can index.
The test sets are the claim¶
tests/data/hy_fold_cases.tsv, tests/data/ka_fold_cases.tsv,
tests/data/ru_fold_cases.tsv and tests/data/syr_fold_cases.tsv in the
repository list groups of spellings that fold together: the cities, the
surnames, the saints and the poets, each in their script (and for
Armenian in both orthographies) and in every scheme that renders them,
plus the popular spellings. The whole set must keep passing, and a
second test checks that different names stay different. The Armenian set
began with the orthography findings of Tetrak brief 014 (Ազգ եւ հայրենիք against Ազգ և հայրենիք, Աւետիքեան against Ավետիքյան);
both grow with the real variants a catalogue turns up. What is not in
them is not claimed; the right way to extend a fold is to add cases
first.
Known gaps¶
Things the folds do not do, written down so nobody assumes they do. Each is a test in the suite, asserting that it does not pass; if a change to the rules closes one, the test moves into the published set.
Armenian:
Popular spellings that insert an unwritten schwa.
Մկրտիչis Mkrtich in every scheme but Megerdich on many a gravestone.Spellings that came through Russian. Khachaturian has a u that
Խաչատրյանdoes not. Russian has no h, and the fold restores it only before o (Ovanes, Ovsep), so Akop and Arutyunyan still miss Hakob and Harutyunyan. A general initial-h rule would also mergeիւր(his) withուր(where).German spellings. Eriwan, Jerewan, Tscharenz, Chatschaturjan, Mikojan: German writes j for
յ, z forց, tsch forչand sch forշ. The fold cannot take them without losing letters every scheme relies on: j isջand z isզin all five, and tsch isտ+շ. A search index that must serve German-language records is better served by indexing a German form beside the Armenian one.Classical
աւthat reformed spelling turned intoօ.աւրandօր(day) do not fold together; the fold readsւas v.ISO 9985 or Hübschmann-Meillet
jwith nothing to show the scheme. In ALA-LC and BGN/PCGNjisջ; in ISO 9985 and Hübschmann-Meillet it isձ. When the text carries none of the marks in rule 2 (a lone Jayn, or arjak ew otanawor), the fold readsjthe ALA-LC way. Passscheme="iso_9985"orscheme="hubschmann_meillet"when you know, and the input is reversed exactly instead.fold_token()sees one token, so it looks for the marks in that token only; fold whole values withfold().իւր(his) andհուր(fire) share a key. Classicalիւbecomesյու, and an initialybecomeshso that Hagop finds Yakob; the two words are then spelt the same. This is an over-merge, not a missed match: a search for one finds the other. Telling them apart would cost theՅ/Հmerge that every Hakob and Hovhannes depends on.The initials
Յ.andՀ.share a key. The same merge, for the lone initial: ALA-LC 2022 writesՅ.as Ḥ. and a keyboard as H., and both must find it. An initial on its own tells little apart.An initial
հեshares a key with an initialե. A classical word beginningյեis the reform’sհե(յեղափոխական,հեղափոխական), and the fold reads it so; but BGN/PCGN, ISO 9985, Hübschmann-Meillet and a catalogue’s ALA-LC write the classical spelling ye, which is also BGN/PCGN’s and Western’s initialե(Yerevan), and a Latin ye cannot say which it was. Until 4.0.0 that was a gap: Yesu missedՅեսու, and a catalogue’s Yeghapʻokhakani missed its ownյեղափոխականի. Now thehgoes on both sides, soՀեթում, Hetum and Yetum are one key and meet a bare Etum. An over-merge, and a rare one: words beginningեandհեthat differ only in theհare few, and the different-names test holds.A real
vbetweeniandois dropped, on both sides. Western writes the glide it says in-իոսnames (Virkilivos forՎիրգիլիոս), and the fold readsivoasiofor every input, soԼիվոռնոand Livorno agree with each other (liorno) and would meet a Liorno. An over-merge, and a rare one.
Georgian:
Russian-mediated forms. Tiflis for
თბილისი, Kutais forქუთაისი.Translated names. George for
გიორგი.The phonetic letters of ISO 9984:2026 Table 5 beyond
ჶ(ჷtoჿ, for sounds standard Georgian does not write) fold to nothing on the script side and are outside the fold’s claim.
Russian:
German and French letters for another sound. German writes ch for
х(Michail, Chruschtschow) and z forц(Zwetajewa); French writes ch forш(Pouchkine) and j forж. Every other spelling uses ch forчand z forз, and those win.The English -off with ch for
х. Rachmaninoff folds to rachmaninov, which misses Rakhmaninov.The English c for
к. Nicolai and Victor missНиколайandВиктор, because c isцin the scholarly and ISO spellings that European library records use.Translated names. Peter for
Пётр, Moscow forМосква.Pre-reform endings and prefixes. The reform changed spelling as well as letters:
-агоbecame-ого(Русскаго,Русского) andбез-becameбес-before a voiceless consonant. Those words differ by a letter that the fold keeps.A glide before e is dropped on both sides.
МайерandМаерshare a key, and so would any two names that differ only by an i or y before an e. An over-merge, and a rare one; the alternative would leave every BGN/PCGN ye and every popular -yev missing its ALA-LC spelling.Armenian, Georgian and other names written in Russian.
Хачатурянfolds as Russian, to khachaturian, and does not meetԽաչատրյան; joining another script’s name to its Russian form is a job for a name authority, not a fold.
Syriac:
Greek, Latin and translated forms of names. Edessa for
ܐܘܪܗܝ(ʾÚrhāy), Nisibis forܢܨܝܒܝܢ(Naṣíbín), Bar Hebraeus forܒܪ ܥܒܪܝܐ, Isaac without theḥofܐܝܣܚܩ. A name authority’s job.Arabic in Syriac letters. Its romanisation writes j for
ܓ(Jirjis); the fold reads j as yod, as in Jacob and Joseph.Words that differ only in alaph, ʿē, waw or yod share a key.
ܥܠ(on) andܠܐ(not) are both l. An over-merge, and the price of a key that every romanisation reaches: the letters they disagree about are exactly these.