// Welsh Base Phonetic Rules
// =========================
// Phonetic rules for Welsh (Cymraeg).
// Celtic language spoken in Wales.
//
// Key features:
// - 8 digraphs treated as single letters: ch, dd, ff, ng, ll, ph, rh, th
// - LL: Unique voiceless lateral fricative [ɬ]
// - W and Y as vowels
// - Circumflex for long vowels: â, ê, î, ô, û, ŵ, ŷ
//
// Rule IDs: 4800-4849
@name "Welsh Base Phonetic Rules"
@version "1.0.0"
@author "liblevenshtein"
@description "Phonetic normalization rules for Welsh"
// ============================================================
// DIGRAPHS (treated as single letters in Welsh)
// ============================================================
// CH → x (voiceless velar fricative, like Scottish "loch")
[id: 4800, name: "ch digraph", weight: 0.05, group: welsh_digraphs, ipa: "/x/"]
ch -> x;
[id: 4801, name: "Ch digraph", weight: 0.05, group: welsh_digraphs, ipa: "/x/"]
Ch -> x;
[id: 4802, name: "CH digraph upper", weight: 0.05, group: welsh_digraphs, ipa: "/x/"]
CH -> x;
// DD → ð (voiced dental fricative, like English "the")
[id: 4803, name: "dd digraph", weight: 0.05, group: welsh_digraphs, ipa: "/ð/"]
dd -> ð;
[id: 4804, name: "Dd digraph", weight: 0.05, group: welsh_digraphs, ipa: "/ð/"]
Dd -> ð;
[id: 4805, name: "DD digraph upper", weight: 0.05, group: welsh_digraphs, ipa: "/ð/"]
DD -> ð;
// FF → f (voiceless labiodental fricative, like English "f")
[id: 4806, name: "ff digraph", weight: 0.05, group: welsh_digraphs, ipa: "/f/"]
ff -> f;
[id: 4807, name: "Ff digraph", weight: 0.05, group: welsh_digraphs, ipa: "/f/"]
Ff -> f;
[id: 4808, name: "FF digraph upper", weight: 0.05, group: welsh_digraphs, ipa: "/f/"]
FF -> f;
// NG → ŋ (velar nasal, like English "sing")
[id: 4809, name: "ng digraph", weight: 0.05, group: welsh_digraphs, ipa: "/ŋ/"]
ng -> ŋ;
[id: 4810, name: "Ng digraph", weight: 0.05, group: welsh_digraphs, ipa: "/ŋ/"]
Ng -> ŋ;
[id: 4811, name: "NG digraph upper", weight: 0.05, group: welsh_digraphs, ipa: "/ŋ/"]
NG -> ŋ;
// LL → ɬ (voiceless lateral fricative - unique Welsh sound!)
[id: 4812, name: "ll digraph", weight: 0.05, group: welsh_digraphs, ipa: "/ɬ/"]
ll -> ɬ;
[id: 4813, name: "Ll digraph", weight: 0.05, group: welsh_digraphs, ipa: "/ɬ/"]
Ll -> ɬ;
[id: 4814, name: "LL digraph upper", weight: 0.05, group: welsh_digraphs, ipa: "/ɬ/"]
LL -> ɬ;
// PH → f (like English "ph" = f)
[id: 4815, name: "ph digraph", weight: 0.05, group: welsh_digraphs, ipa: "/f/"]
ph -> f;
[id: 4816, name: "Ph digraph", weight: 0.05, group: welsh_digraphs, ipa: "/f/"]
Ph -> f;
[id: 4817, name: "PH digraph upper", weight: 0.05, group: welsh_digraphs, ipa: "/f/"]
PH -> f;
// RH → r̥ (voiceless alveolar trill)
[id: 4818, name: "rh digraph", weight: 0.05, group: welsh_digraphs, ipa: "/r̥/"]
rh -> r̥;
[id: 4819, name: "Rh digraph", weight: 0.05, group: welsh_digraphs, ipa: "/r̥/"]
Rh -> r̥;
[id: 4820, name: "RH digraph upper", weight: 0.05, group: welsh_digraphs, ipa: "/r̥/"]
RH -> r̥;
// TH → θ (voiceless dental fricative, like English "think")
[id: 4821, name: "th digraph", weight: 0.05, group: welsh_digraphs, ipa: "/θ/"]
th -> θ;
[id: 4822, name: "Th digraph", weight: 0.05, group: welsh_digraphs, ipa: "/θ/"]
Th -> θ;
[id: 4823, name: "TH digraph upper", weight: 0.05, group: welsh_digraphs, ipa: "/θ/"]
TH -> θ;
// ============================================================
// LONG VOWELS (circumflex)
// ============================================================
[id: 4824, name: "a circumflex", weight: 0.1, group: welsh_long_vowels]
â -> a;
[id: 4825, name: "A circumflex", weight: 0.1, group: welsh_long_vowels]
 -> a;
[id: 4826, name: "e circumflex", weight: 0.1, group: welsh_long_vowels]
ê -> e;
[id: 4827, name: "E circumflex", weight: 0.1, group: welsh_long_vowels]
Ê -> e;
[id: 4828, name: "i circumflex", weight: 0.1, group: welsh_long_vowels]
î -> i;
[id: 4829, name: "I circumflex", weight: 0.1, group: welsh_long_vowels]
Î -> i;
[id: 4830, name: "o circumflex", weight: 0.1, group: welsh_long_vowels]
ô -> o;
[id: 4831, name: "O circumflex", weight: 0.1, group: welsh_long_vowels]
Ô -> o;
[id: 4832, name: "u circumflex", weight: 0.1, group: welsh_long_vowels]
û -> u;
[id: 4833, name: "U circumflex", weight: 0.1, group: welsh_long_vowels]
Û -> u;
[id: 4834, name: "w circumflex", weight: 0.1, group: welsh_long_vowels]
ŵ -> w;
[id: 4835, name: "W circumflex", weight: 0.1, group: welsh_long_vowels]
Ŵ -> w;
[id: 4836, name: "y circumflex", weight: 0.1, group: welsh_long_vowels]
ŷ -> y;
[id: 4837, name: "Y circumflex", weight: 0.1, group: welsh_long_vowels]
Ŷ -> y;
// ============================================================
// STANDARD VOWELS (including W and Y as vowels)
// ============================================================
// Note: Standard vowels (a, e, i, o, u, w, y) pass through unchanged.
// Identity mappings removed as they are no-ops - unmapped characters
// pass through the phonetic transformation unchanged.
// ============================================================
// CONSONANTS
// ============================================================
// C → k (always pronounced as k in Welsh)
[id: 4854, name: "c consonant", weight: 0.2, group: welsh_consonants]
c -> k;
[id: 4855, name: "C consonant", weight: 0.2, group: welsh_consonants]
C -> k;
// F in Welsh = v sound (ff = f sound)
[id: 4858, name: "f consonant", weight: 0.2, group: welsh_consonants, ipa: "/v/"]
f -> v;
[id: 4859, name: "F consonant", weight: 0.2, group: welsh_consonants, ipa: "/v/"]
F -> v;
// J → d͡ʒ (not native to Welsh, used in loanwords)
[id: 4864, name: "j consonant", weight: 0.2, group: welsh_consonants, ipa: "/d͡ʒ/"]
j -> d͡ʒ;
[id: 4865, name: "J consonant", weight: 0.2, group: welsh_consonants, ipa: "/d͡ʒ/"]
J -> d͡ʒ;
// Note: Other consonants (b, d, g, h, l, m, n, p, r, s, t) pass through unchanged.
// Identity mappings removed as they are no-ops - unmapped characters
// pass through the phonetic transformation unchanged.
// ============================================================
// SOFT MUTATION (Treiglad Meddal)
// ============================================================
// Soft mutation is the most common mutation in Welsh, occurring after:
// - Feminine singular nouns (with adjectives)
// - Direct object of a verb
// - After certain prepositions (am, ar, at, dan, dros, drwy, heb, hyd, i, o, tan, wrth)
// - After dy (your), ei (his), and other possessives
//
// These rules provide alternative phonetic representations for mutated forms.
// The input text may contain either the radical or mutated form.
// p → b (e.g., pen → ben)
[id: 4870, name: "soft mutation p to b", weight: 0.05, group: welsh_soft_mutation]
p -> b;
// t → d (e.g., tad → dad)
[id: 4871, name: "soft mutation t to d", weight: 0.05, group: welsh_soft_mutation]
t -> d;
// c → ɡ (e.g., car → gar)
// Note: Using IPA ɡ (U+0261) for consistency
[id: 4872, name: "soft mutation c to g", weight: 0.05, group: welsh_soft_mutation, ipa: "/ɡ/"]
c -> ɡ;
// b → v (e.g., baban → faban) - Welsh 'f' sounds like 'v'
[id: 4873, name: "soft mutation b to f/v", weight: 0.05, group: welsh_soft_mutation, ipa: "/v/"]
b -> v;
// d → ð (e.g., drws → ddrws) - Welsh 'dd' sounds like 'ð'
[id: 4874, name: "soft mutation d to dd", weight: 0.05, group: welsh_soft_mutation, ipa: "/ð/"]
d -> ð;
// g → (deleted) (e.g., gardd → ardd)
// Note: g is deleted in soft mutation, but we keep the mapping
// as g -> g with low weight since deletion is context-dependent
[id: 4875, name: "soft mutation g deletion", weight: 0.05, group: welsh_soft_mutation]
g -> ;
// m → v (e.g., mam → fam) - mutated to 'f' which sounds like 'v'
[id: 4876, name: "soft mutation m to f/v", weight: 0.05, group: welsh_soft_mutation, ipa: "/v/"]
m -> v;
// ll → l (e.g., llaw → law) - ɬ becomes plain l
[id: 4877, name: "soft mutation ll to l", weight: 0.05, group: welsh_soft_mutation]
ɬ -> l;
// rh → r (e.g., rhad → rad) - voiceless r becomes voiced r
[id: 4878, name: "soft mutation rh to r", weight: 0.05, group: welsh_soft_mutation]
r̥ -> r;
// ============================================================
// NASAL MUTATION (Treiglad Trwynol)
// ============================================================
// Occurs after 'yn' (in), 'fy' (my).
// Less common than soft mutation.
// p → mh (aspirated m)
[id: 4880, name: "nasal mutation p to mh", weight: 0.08, group: welsh_nasal_mutation]
p -> mh;
// t → nh (aspirated n)
[id: 4881, name: "nasal mutation t to nh", weight: 0.08, group: welsh_nasal_mutation]
t -> nh;
// c → ŋh (ngh - aspirated ng)
[id: 4882, name: "nasal mutation c to ngh", weight: 0.08, group: welsh_nasal_mutation]
c -> ŋh;
// b → m
[id: 4883, name: "nasal mutation b to m", weight: 0.08, group: welsh_nasal_mutation]
b -> m;
// d → n
[id: 4884, name: "nasal mutation d to n", weight: 0.08, group: welsh_nasal_mutation]
d -> n;
// g → ŋ (ng)
[id: 4885, name: "nasal mutation g to ng", weight: 0.08, group: welsh_nasal_mutation, ipa: "/ŋ/"]
g -> ŋ;
// ============================================================
// ASPIRATE MUTATION (Treiglad Llaes)
// ============================================================
// Occurs after 'a' (and, with), 'â' (with), 'ei' (her), 'tri/tair' (three).
// Only affects p, t, c.
// p → f (ph in Welsh = f sound)
[id: 4886, name: "aspirate mutation p to ph", weight: 0.08, group: welsh_aspirate_mutation]
p -> f;
// t → θ (th)
[id: 4887, name: "aspirate mutation t to th", weight: 0.08, group: welsh_aspirate_mutation, ipa: "/θ/"]
t -> θ;
// c → x (ch)
[id: 4888, name: "aspirate mutation c to ch", weight: 0.08, group: welsh_aspirate_mutation, ipa: "/x/"]
c -> x;