// Russian Base Phonetic Rules
// ===========================
// Phonetic rules for Standard Russian (Русский язык).
// Maps Cyrillic script to Latin phonetic representations.
//
// Key features:
// - Cyrillic to Latin transliteration
// - Vowel reduction (о in unstressed positions)
// - Final devoicing
// - Soft consonants (before ь and soft vowels)
// - Iotated vowels (е, ё, ю, я → ye, yo, yu, ya)
//
// Rule IDs: 2000-2099
@name "Russian Base Phonetic Rules"
@version "1.0.0"
@author "liblevenshtein"
@description "Phonetic normalization rules for Standard Russian"
// ============================================================
// MULTI-CHARACTER PATTERNS (highest priority)
// ============================================================
// ЩЩ double consonant → ɕː (long palatal fricative)
[id: 2000, name: "щщ to ɕː", weight: 0.05, group: russian_doubles, ipa: "/ɕː/"]
щщ -> ɕː;
// ЖЖ double consonant → ʒ
[id: 2001, name: "жж to ʒ", weight: 0.05, group: russian_doubles, ipa: "/ʒ/"]
жж -> ʒ;
// ШШ double consonant → ʃ
[id: 2002, name: "шш to ʃ", weight: 0.05, group: russian_doubles, ipa: "/ʃ/"]
шш -> ʃ;
// ЦЦ double consonant → t͡s
[id: 2003, name: "цц to t͡s", weight: 0.05, group: russian_doubles, ipa: "/t͡s/"]
цц -> t͡s;
// ЧЧ double consonant → t͡ʃ
[id: 2004, name: "чч to t͡ʃ", weight: 0.05, group: russian_doubles, ipa: "/t͡ʃ/"]
чч -> t͡ʃ;
// ============================================================
// COMPLEX CONSONANTS (before simple consonants)
// ============================================================
// Щ → ɕː (voiceless alveolo-palatal fricative, long)
[id: 2010, name: "щ to ɕː", weight: 0.1, group: russian_complex, ipa: "/ɕː/"]
щ -> ɕː;
[id: 2011, name: "Щ to ɕː", weight: 0.1, group: russian_complex, ipa: "/ɕː/"]
Щ -> ɕː;
// Ж → ʒ (voiced postalveolar fricative)
[id: 2012, name: "ж to ʒ", weight: 0.1, group: russian_complex, ipa: "/ʒ/"]
ж -> ʒ;
[id: 2013, name: "Ж to ʒ", weight: 0.1, group: russian_complex, ipa: "/ʒ/"]
Ж -> ʒ;
// Ш → ʃ (voiceless postalveolar fricative)
[id: 2014, name: "ш to ʃ", weight: 0.1, group: russian_complex, ipa: "/ʃ/"]
ш -> ʃ;
[id: 2015, name: "Ш to ʃ", weight: 0.1, group: russian_complex, ipa: "/ʃ/"]
Ш -> ʃ;
// Х → x (voiceless velar fricative)
[id: 2016, name: "х to x", weight: 0.1, group: russian_complex, ipa: "/x/"]
х -> x;
[id: 2017, name: "Х to x", weight: 0.1, group: russian_complex, ipa: "/x/"]
Х -> x;
// Ц → t͡s (voiceless alveolar affricate)
[id: 2018, name: "ц to t͡s", weight: 0.1, group: russian_complex, ipa: "/t͡s/"]
ц -> t͡s;
[id: 2019, name: "Ц to t͡s", weight: 0.1, group: russian_complex, ipa: "/t͡s/"]
Ц -> t͡s;
// Ч → t͡ʃ (voiceless postalveolar affricate)
[id: 2020, name: "ч to t͡ʃ", weight: 0.1, group: russian_complex, ipa: "/t͡ʃ/"]
ч -> t͡ʃ;
[id: 2021, name: "Ч to t͡ʃ", weight: 0.1, group: russian_complex, ipa: "/t͡ʃ/"]
Ч -> t͡ʃ;
// ============================================================
// IOTATED VOWELS (vowels with initial /j/)
// ============================================================
// These vowels contain a "y" sound at the start
// Е → je (or e after consonants - simplified to je for matching)
[id: 2025, name: "е to je", weight: 0.15, group: russian_iotated, ipa: "/je/"]
е -> je;
[id: 2026, name: "Е to je", weight: 0.15, group: russian_iotated, ipa: "/je/"]
Е -> je;
// Ё → jo (always stressed, always iotated)
[id: 2027, name: "ё to jo", weight: 0.15, group: russian_iotated, ipa: "/jo/"]
ё -> jo;
[id: 2028, name: "Ё to jo", weight: 0.15, group: russian_iotated, ipa: "/jo/"]
Ё -> jo;
// Ю → ju
[id: 2029, name: "ю to ju", weight: 0.15, group: russian_iotated, ipa: "/ju/"]
ю -> ju;
[id: 2030, name: "Ю to ju", weight: 0.15, group: russian_iotated, ipa: "/ju/"]
Ю -> ju;
// Я → ja
[id: 2031, name: "я to ja", weight: 0.15, group: russian_iotated, ipa: "/ja/"]
я -> ja;
[id: 2032, name: "Я to ja", weight: 0.15, group: russian_iotated, ipa: "/ja/"]
Я -> ja;
// ============================================================
// SIMPLE VOWELS
// ============================================================
// А → a
[id: 2035, name: "а to a", weight: 0.2, group: russian_vowels]
а -> a;
[id: 2036, name: "А to a", weight: 0.2, group: russian_vowels]
А -> a;
// Э → e (open e, like "bed")
[id: 2037, name: "э to e", weight: 0.2, group: russian_vowels]
э -> e;
[id: 2038, name: "Э to e", weight: 0.2, group: russian_vowels]
Э -> e;
// И → i
[id: 2039, name: "и to i", weight: 0.2, group: russian_vowels]
и -> i;
[id: 2040, name: "И to i", weight: 0.2, group: russian_vowels]
И -> i;
// О → o
[id: 2041, name: "о to o", weight: 0.2, group: russian_vowels]
о -> o;
[id: 2042, name: "О to o", weight: 0.2, group: russian_vowels]
О -> o;
// У → u
[id: 2043, name: "у to u", weight: 0.2, group: russian_vowels]
у -> u;
[id: 2044, name: "У to u", weight: 0.2, group: russian_vowels]
У -> u;
// Ы → ɨ (unique Russian vowel, close central unrounded)
[id: 2045, name: "ы to ɨ", weight: 0.2, group: russian_vowels, ipa: "/ɨ/"]
ы -> ɨ;
[id: 2046, name: "Ы to ɨ", weight: 0.2, group: russian_vowels, ipa: "/ɨ/"]
Ы -> ɨ;
// ============================================================
// SIMPLE CONSONANTS
// ============================================================
// Б → b
[id: 2050, name: "б to b", weight: 0.25, group: russian_consonants]
б -> b;
[id: 2051, name: "Б to b", weight: 0.25, group: russian_consonants]
Б -> b;
// В → v
[id: 2052, name: "в to v", weight: 0.25, group: russian_consonants]
в -> v;
[id: 2053, name: "В to v", weight: 0.25, group: russian_consonants]
В -> v;
// Г → ɡ
[id: 2054, name: "г to ɡ", weight: 0.25, group: russian_consonants, ipa: "/ɡ/"]
г -> ɡ;
[id: 2055, name: "Г to ɡ", weight: 0.25, group: russian_consonants, ipa: "/ɡ/"]
Г -> ɡ;
// Д → d
[id: 2056, name: "д to d", weight: 0.25, group: russian_consonants]
д -> d;
[id: 2057, name: "Д to d", weight: 0.25, group: russian_consonants]
Д -> d;
// З → z
[id: 2058, name: "з to z", weight: 0.25, group: russian_consonants]
з -> z;
[id: 2059, name: "З to z", weight: 0.25, group: russian_consonants]
З -> z;
// Й → j (palatal approximant)
[id: 2060, name: "й to j", weight: 0.25, group: russian_consonants, ipa: "/j/"]
й -> j;
[id: 2061, name: "Й to j", weight: 0.25, group: russian_consonants, ipa: "/j/"]
Й -> j;
// К → k
[id: 2062, name: "к to k", weight: 0.25, group: russian_consonants]
к -> k;
[id: 2063, name: "К to k", weight: 0.25, group: russian_consonants]
К -> k;
// Л → l
[id: 2064, name: "л to l", weight: 0.25, group: russian_consonants]
л -> l;
[id: 2065, name: "Л to l", weight: 0.25, group: russian_consonants]
Л -> l;
// М → m
[id: 2066, name: "м to m", weight: 0.25, group: russian_consonants]
м -> m;
[id: 2067, name: "М to m", weight: 0.25, group: russian_consonants]
М -> m;
// Н → n
[id: 2068, name: "н to n", weight: 0.25, group: russian_consonants]
н -> n;
[id: 2069, name: "Н to n", weight: 0.25, group: russian_consonants]
Н -> n;
// П → p
[id: 2070, name: "п to p", weight: 0.25, group: russian_consonants]
п -> p;
[id: 2071, name: "П to p", weight: 0.25, group: russian_consonants]
П -> p;
// Р → r
[id: 2072, name: "р to r", weight: 0.25, group: russian_consonants]
р -> r;
[id: 2073, name: "Р to r", weight: 0.25, group: russian_consonants]
Р -> r;
// С → s
[id: 2074, name: "с to s", weight: 0.25, group: russian_consonants]
с -> s;
[id: 2075, name: "С to s", weight: 0.25, group: russian_consonants]
С -> s;
// Т → t
[id: 2076, name: "т to t", weight: 0.25, group: russian_consonants]
т -> t;
[id: 2077, name: "Т to t", weight: 0.25, group: russian_consonants]
Т -> t;
// Ф → f
[id: 2078, name: "ф to f", weight: 0.25, group: russian_consonants]
ф -> f;
[id: 2079, name: "Ф to f", weight: 0.25, group: russian_consonants]
Ф -> f;
// ============================================================
// SOFT AND HARD SIGNS
// ============================================================
// These modify the preceding consonant but have no sound of their own
// Ь (soft sign) → remove (marks palatalization)
[id: 2085, name: "soft sign remove", weight: 0.3, group: russian_signs]
ь -> ;
[id: 2086, name: "Soft sign remove", weight: 0.3, group: russian_signs]
Ь -> ;
// Ъ (hard sign) → remove (marks separation, no longer used much)
[id: 2087, name: "hard sign remove", weight: 0.3, group: russian_signs]
ъ -> ;
[id: 2088, name: "Hard sign remove", weight: 0.3, group: russian_signs]
Ъ -> ;
// ============================================================
// FINAL DEVOICING (at word end)
// ============================================================
// Voiced consonants become voiceless at word end
// Must run BEFORE transliteration (lower weight = earlier)
[id: 2090, name: "final б to p", weight: 0.08, group: russian_devoicing]
б -> p / _#;
[id: 2091, name: "final в to f", weight: 0.08, group: russian_devoicing]
в -> f / _#;
[id: 2092, name: "final г to k", weight: 0.08, group: russian_devoicing]
г -> k / _#;
[id: 2093, name: "final д to t", weight: 0.08, group: russian_devoicing]
д -> t / _#;
[id: 2094, name: "final ж to ʃ", weight: 0.08, group: russian_devoicing, ipa: "/ʃ/"]
ж -> ʃ / _#;
[id: 2095, name: "final з to s", weight: 0.08, group: russian_devoicing]
з -> s / _#;
// ============================================================
// DOUBLE CONSONANT SIMPLIFICATION (Latin output)
// ============================================================
// After transliteration, simplify double Latin consonants
[id: 2096, name: "bb to b", weight: 0.4, group: russian_latin_doubles]
bb -> b;
[id: 2097, name: "dd to d", weight: 0.4, group: russian_latin_doubles]
dd -> d;
[id: 2098, name: "ff to f", weight: 0.4, group: russian_latin_doubles]
ff -> f;
[id: 2099, name: "kk to k", weight: 0.4, group: russian_latin_doubles]
kk -> k;
// ============================================================
// VOWEL REDUCTION (Akan'e and Ikan'e)
// ============================================================
// In Standard (Moscow) Russian, vowels reduce in unstressed positions:
// - Akan'e (аканье): /о/ → [ɐ] unstressed (sounds like reduced 'a')
// - Ikan'e (иканье): /е/, /я/ → [ɪ] unstressed (sounds like reduced 'i')
//
// These rules provide alternative phonetic representations for reduced vowels.
// Since stress is not marked in standard Russian text, we provide both
// the full and reduced forms as alternatives.
// о → ɐ (unstressed 'o' reduces to near-open central vowel)
[id: 2800, name: "akan'e o reduction", weight: 0.15, group: russian_reduction, ipa: "/ɐ/"]
o -> ɐ;
// е (after transliteration: je or e) → ɪ (unstressed 'e' reduces)
[id: 2801, name: "ikan'e je reduction", weight: 0.15, group: russian_reduction, ipa: "/ɪ/"]
je -> ɪ;
// е after consonants becomes just e, which also reduces
[id: 2802, name: "ikan'e e reduction", weight: 0.15, group: russian_reduction, ipa: "/ɪ/"]
e -> ɪ;
// я (after transliteration: ja) → ɪ (unstressed 'ya' reduces to 'i'-like)
[id: 2803, name: "ikan'e ja reduction", weight: 0.15, group: russian_reduction, ipa: "/ɪ/"]
ja -> ɪ;
// а → ɐ (unstressed 'a' also reduces to near-open central)
// In pretonic (immediately before stress) position, this is common
[id: 2804, name: "a reduction", weight: 0.18, group: russian_reduction, ipa: "/ɐ/"]
a -> ɐ;
// ============================================================
// BEIDER-MORSE SLAVIC RULES
// ============================================================
// Additional rules derived from the Beider-Morse Phonetic Matching
// algorithm for Russian and other Slavic languages.
// ID Range: 3400-3499
@define VOWEL_RU = [aeiouɐɨɪ]
@define CONSONANT_RU = [bcdfghjklmnpqrstvwxz]
// ------------------------------------------------------------
// Regressive Voicing Assimilation
// ------------------------------------------------------------
// Russian has regressive voicing assimilation like Polish
[id: 3400, name: "vk to fk russian", weight: 0.10, group: bm_russian_assimilation]
vk -> fk;
[id: 3401, name: "vp to fp russian", weight: 0.10, group: bm_russian_assimilation]
vp -> fp;
[id: 3402, name: "vt to ft russian", weight: 0.10, group: bm_russian_assimilation]
vt -> ft;
[id: 3403, name: "vs to fs russian", weight: 0.10, group: bm_russian_assimilation]
vs -> fs;
[id: 3404, name: "zk to sk russian", weight: 0.10, group: bm_russian_assimilation]
zk -> sk;
[id: 3405, name: "zp to sp russian", weight: 0.10, group: bm_russian_assimilation]
zp -> sp;
[id: 3406, name: "zt to st russian", weight: 0.10, group: bm_russian_assimilation]
zt -> st;
[id: 3407, name: "zs to ss russian", weight: 0.10, group: bm_russian_assimilation]
zs -> ss;
[id: 3408, name: "bk to pk russian", weight: 0.10, group: bm_russian_assimilation]
bk -> pk;
[id: 3409, name: "dk to tk russian", weight: 0.10, group: bm_russian_assimilation]
dk -> tk;
[id: 3410, name: "gk to kk russian", weight: 0.10, group: bm_russian_assimilation]
gk -> kk;
// Progressive assimilation (voiceless before voiced)
[id: 3411, name: "kb to gb russian", weight: 0.10, group: bm_russian_assimilation]
kb -> gb;
[id: 3412, name: "sb to zb russian", weight: 0.10, group: bm_russian_assimilation]
sb -> zb;
[id: 3413, name: "sd to zd russian", weight: 0.10, group: bm_russian_assimilation]
sd -> zd;
// ------------------------------------------------------------
// G Weakening Patterns
// ------------------------------------------------------------
// In some positions, г becomes в or х
[id: 3420, name: "ogo to ovo russian", weight: 0.15, group: bm_russian_g]
// -ОГО genitive -> pronounced as -ОВО (его, того, красного)
ogo -> ovo;
[id: 3421, name: "ego to evo russian", weight: 0.15, group: bm_russian_g]
// -ЕГО genitive
ego -> evo;
[id: 3422, name: "ogo to ava russian", weight: 0.20, group: bm_russian_g]
// -АГО old spelling
ago -> avo;
// ------------------------------------------------------------
// Palatalization Patterns
// ------------------------------------------------------------
// Consonants before soft vowels are palatalized
[id: 3425, name: "ti palatalization", weight: 0.10, group: bm_russian_palatal, ipa: "/tʲi/"]
// T before I: palatalized
ti -> tʲi;
[id: 3426, name: "di palatalization", weight: 0.10, group: bm_russian_palatal, ipa: "/dʲi/"]
// D before I: palatalized
di -> dʲi;
[id: 3427, name: "ni palatalization", weight: 0.10, group: bm_russian_palatal, ipa: "/ɲi/"]
// N before I: palatalized
ni -> ɲi;
[id: 3428, name: "li palatalization", weight: 0.10, group: bm_russian_palatal, ipa: "/lʲi/"]
// L before I: palatalized (different from "hard" L)
li -> lʲi;
[id: 3429, name: "si palatalization", weight: 0.10, group: bm_russian_palatal, ipa: "/ɕi/"]
// S before I: approaches ɕ
si -> ɕi;
[id: 3430, name: "zi palatalization", weight: 0.10, group: bm_russian_palatal, ipa: "/ʑi/"]
// Z before I
zi -> ʑi;
// ------------------------------------------------------------
// TS Cluster Patterns
// ------------------------------------------------------------
[id: 3435, name: "dts to ts russian", weight: 0.10, group: bm_russian_cluster, ipa: "/t͡s/"]
// ДТС cluster (as in "двадцать"): pronounced as ts
dts -> t͡s;
[id: 3436, name: "tts to ts russian", weight: 0.10, group: bm_russian_cluster, ipa: "/t͡s/"]
// ТТС cluster: simplified
tts -> t͡s;
[id: 3437, name: "cts to ts russian", weight: 0.10, group: bm_russian_cluster, ipa: "/t͡s/"]
// ЦТС: simplified
cts -> t͡s;
// ------------------------------------------------------------
// STN/ZDN Simplification
// ------------------------------------------------------------
// Some consonant clusters simplify in speech
[id: 3440, name: "stn to sn russian", weight: 0.15, group: bm_russian_simplify]
// СТН -> СН (честный -> чесный in casual speech)
stn -> sn;
[id: 3441, name: "zdn to zn russian", weight: 0.15, group: bm_russian_simplify]
// ЗДН -> ЗН (поздно -> позно in casual speech)
zdn -> zn;
[id: 3442, name: "stl to sl russian", weight: 0.15, group: bm_russian_simplify]
// СТЛ -> СЛ (счастливый)
stl -> sl;
[id: 3443, name: "rdn to rn russian", weight: 0.15, group: bm_russian_simplify]
// РДН -> РН (сердце)
rdn -> rn;
[id: 3444, name: "rdc to rc russian", weight: 0.15, group: bm_russian_simplify]
// РДЦ -> РЦ (сердце)
rdc -> rc;
[id: 3445, name: "lnc to nc russian", weight: 0.15, group: bm_russian_simplify]
// ЛНЦ -> НЦ (солнце -> сонце)
lnc -> nc;
// ------------------------------------------------------------
// Cross-Slavic Patterns
// ------------------------------------------------------------
[id: 3450, name: "w to v russian", weight: 0.20, group: bm_russian_cross]
// W -> V: Polish/German names in Russian
w -> v;
[id: 3451, name: "ow to ov russian", weight: 0.15, group: bm_russian_cross]
// -OW: German/Polish ending
ow -> ov / _#;
[id: 3452, name: "ew to ev russian", weight: 0.15, group: bm_russian_cross]
// -EW: German/Polish ending
ew -> ev / _#;
[id: 3453, name: "cz to ch russian", weight: 0.15, group: bm_russian_cross, ipa: "/t͡ʃ/"]
// CZ: Polish spelling in Russian context
cz -> t͡ʃ;
[id: 3454, name: "sz to sh russian", weight: 0.15, group: bm_russian_cross, ipa: "/ʃ/"]
// SZ: Polish spelling
sz -> ʃ;
// ------------------------------------------------------------
// Name Suffix Patterns
// ------------------------------------------------------------
[id: 3460, name: "ov name suffix", weight: 0.05, group: bm_russian_name_suffix]
// -ОВ: Most common surname ending
ov -> of / _#;
[id: 3461, name: "ev name suffix", weight: 0.05, group: bm_russian_name_suffix]
// -ЕВ: After soft consonants
ev -> ef / _#;
[id: 3462, name: "in name suffix", weight: 0.10, group: bm_russian_name_suffix]
// -ИН: Pushkin, Rasputin
in -> in / _#;
[id: 3463, name: "enko name suffix", weight: 0.10, group: bm_russian_name_suffix]
// -ЕНКО: Ukrainian names
enko -> enko / _#;
[id: 3464, name: "ko name suffix", weight: 0.10, group: bm_russian_name_suffix]
// -КО: Ukrainian names
ko -> ko / _#;
// ------------------------------------------------------------
// TSS/STS Simplification
// ------------------------------------------------------------
[id: 3470, name: "tss to ts russian", weight: 0.10, group: bm_russian_geminate, ipa: "/t͡s/"]
// Double TS simplified
tss -> t͡s;
[id: 3471, name: "sss to ss russian", weight: 0.10, group: bm_russian_geminate]
// Triple S simplified
sss -> ss;
[id: 3472, name: "mmm to mm russian", weight: 0.10, group: bm_russian_geminate]
// Triple M simplified
mmm -> mm;
[id: 3473, name: "nnn to nn russian", weight: 0.10, group: bm_russian_geminate]
// Triple N simplified
nnn -> nn;