Module:siwa-pron: Difference between revisions

No edit summary
No edit summary
Line 15: Line 15:


local function rsub(term, foo, bar, n)
local function rsub(term, foo, bar, n)
local retval = gsub(term, foo, bar, n)
local retval = mw.ustring.gsub(term, foo, bar, n)
return retval
return retval
end
end
Line 75: Line 75:


local rules = {
local rules = {
{".", {
{".", {
["ḍ"] = "ð", ["ṡ"] = "ɕ",
["ḍ"] = "ð", ["ṡ"] = "ɕ",
["ḥ"] = "ʔ", ["į"] = "j",
["ḥ"] = "ʔ", ["į"] = "j",
["ġ"] = "x", ["g"] = "ɡ", -- IPA g
["ġ"] = "x", ["g"] = "ɡ", -- IPA g
}},
}},
{"t[ṡɕ]", "ʨ"}, {"dj", "ʥ"}, {"dl", "ł"}, {"kj", "c"}, {"nj", "ɲ"},  {"ts", "ʦ"},
{"t[ṡɕ]", "ʨ"}, {"dj", "ʥ"}, {"dl", "ł"}, {"kj", "c"}, {"nj", "ɲ"},  {"ts", "ʦ"},
-- long consonants
-- long consonants
{"mm", "mː"}, {"bb", "pː"}, {"vv", "wː"}, {"nn", "nː"},
{"mm", "mː"}, {"bb", "pː"}, {"vv", "wː"}, {"nn", "nː"},
{"dʥ", "ʥː"}, {"dd", "tː"}, {"ðð", "ðː"}, {"ss", "sː"},
{"dʥ", "ʥː"}, {"dd", "tː"}, {"ðð", "ðː"}, {"ss", "sː"},
{"ɕɕ", "ɕː"}, {"rr", "rː"}, {"ll", "lː"}, {"ɡɡ", "kː"},
{"ɕɕ", "ɕː"}, {"rr", "rː"}, {"ll", "lː"}, {"ɡɡ", "kː"},
{"xx", "xː"}, {"nɡ", "ŋː"}, {"hh", "hː"}, {"ʔʔ", "ʔː"},
{"xx", "xː"}, {"nɡ", "ŋː"}, {"hh", "hː"}, {"ʔʔ", "ʔː"},
{"nɲ", "ɲː"}, {"hl", "ɬː"},
{"nɲ", "ɲː"}, {"hl", "ɬː"},
-- default all consonants to unstressed. [] with stroke and ꬶ (U+AB36) to tell apart natural and stress-borne
-- default all consonants to unstressed. [] with stroke and ꬶ (U+AB36) to tell apart natural and stress-borne
{"p", "ƀ"}, {"d", "ꝺ"}, {"t", "đ"}, {"ɡ", "ɣ"}, {"k", "ꬶ"},
{"p", "ƀ"}, {"d", "ꝺ"}, {"t", "đ"}, {"ɡ", "ɣ"}, {"k", "ꬶ"},
-- default all vowels to open (open-closed distinctions are computed later); long vowels don't have closed counterparts
-- default all vowels to open (open-closed distinctions are computed later); long vowels don't have closed counterparts
{"a", "ɑ"}, {"ę", "æ"}, {"o", "ɔ"}, {"ů", "ø"}, {"õ", "ɔ̃"},
{"a", "ɑ"}, {"ę", "æ"}, {"o", "ɔ"}, {"ů", "ø"}, {"õ", "ɔ̃"},
{"ả", "æː"}, {"ẻ", "eː"}, {"ỉ", "iː"}, {"ỏ", "ʊː"}, {"ủ", "uː"}, {"ỷ", "yː"}, {"ẻu", "øː"}, {"õu", "ɔ̃ː̃"},
{"ả", "æː"}, {"ẻ", "eː"}, {"ỉ", "iː"}, {"ỏ", "ʊː"}, {"ủ", "uː"}, {"ỷ", "yː"}, {"ẻu", "øː"}, {"õu", "ɔ̃ː̃"},
{"^(ˈ)ꬶ([" .. front_vowel .. "])", "%1c%2"}, -- word-initial [k] palatalizes before front-vowels
{"^(ˈ)ꬶ([" .. front_vowel .. "])", "%1c%2"}, -- word-initial [k] palatalizes before front-vowels
{"^(ˈ[ƀđꬶc])", "%1ʰ"}, -- voiceless stops word-initially become aspirated
{"^(ˈ[ƀđꬶc])", "%1ʰ"}, -- voiceless stops word-initially become aspirated
{"^(.*·ˈ[ƀđꬶc])", "%1⁽ʰ⁾"}, -- although after a prefix they may or may not be
{"^(.*·ˈ[ƀđꬶc])", "%1⁽ʰ⁾"}, -- although after a prefix they may or may not be
{"^(ˈ)ɣj([" .. front_vowel .. "])", "%1ʣ%2"}, -- <gį> word-initially and before front vowels is pronounced [d͡z]
{"^(ˈ)ɣj([" .. front_vowel .. "])", "%1ʣ%2"}, -- <gį> word-initially and before front vowels is pronounced [d͡z]
{"^(ˈ)ɣj([" .. back_vowel .. "])", "%1ɟ%2"}, -- and [ɟ] before back vowels
{"^(ˈ)ɣj([" .. back_vowel .. "])", "%1ɟ%2"}, -- and [ɟ] before back vowels
{"^(ˈ)ɣ([" .. front_vowel .. "])", "%1ɟ%2"}, -- ɣ > ɟ / #_[+back]
{"^(ˈ)ɣ([" .. front_vowel .. "])", "%1ɟ%2"}, -- ɣ > ɟ / #_[+back]


-- other stem- and/or word-initial configurations
-- other stem- and/or word-initial configurations
{"đi", "ʨi"}, {"ꝺi", "ʥi"}, {"ɣi", "ɉi"}, {"ɣj", "jː"}, {"ɣjː", "ɟː"},
{"đi", "ʨi"}, {"ꝺi", "ʥi"}, {"ɣi", "ɉi"}, {"ɣj", "jː"}, {"ɣjː", "ɟː"},
{"ˈƀ", "ˈp"}, {"ˈđ", "ˈt"}, {"ˈꬶ", "ˈk"}, {"ˈꝺ", "ˈd"},
{"ˈƀ", "ˈp"}, {"ˈđ", "ˈt"}, {"ˈꬶ", "ˈk"}, {"ˈꝺ", "ˈd"},
-- stressed consonants (coda of stressed syllables without long vowels, diphthongs, or triphthongs)
{spat1, "%1ʔ%3"}, {spat2, "%1k%3"}, {spat3, "%1p%3"}, {spat4, "%1t%3"}, {spat5, "%1ð%3"},


-- stressed consonants (coda of stressed syllables without long vowels, diphthongs, or triphthongs)
-- internal consonant clusters
{spat1, "%1ʔ%3"}, {spat2, "%1k%3"}, {spat3, "%1p%3"}, {spat4, "%1t%3"}, {spat5, "%1ð%3"},
{"ƀƀ", "ʔp"}, {"pƀ", "ʔp"},
{"đđ", "ʔt"}, {"tđ", "ʔt"},
-- internal consonant clusters
{"ꬶꬶ", "ʔk"}, {"kꬶ", "ʔk"},
{"ƀƀ", "ʔp"}, {"pƀ", "ʔp"},
{"bm", "ʔp̚m"}, {"ꝺn", "ʔt̚n"}, {"ꬶn", "ʔk̚ŋ"},
{"đđ", "ʔt"}, {"tđ", "ʔt"},
{"mn", "mnː"}, {"mʔk", "mkː"},
{"ꬶꬶ", "ʔk"}, {"kꬶ", "ʔk"},
{"(p[msɕ])", "%1ː"}, {"pr", "px"},
{"bm", "ʔp̚m"}, {"ꝺn", "ʔt̚n"}, {"ꬶn", "ʔk̚ŋ"},
{"b([sɕ])", "p%1"},
{"mn", "mnː"}, {"mʔk", "mkː"},
{"nꬶ", "ŋk"}, {"([ðđʦłɕꬶr])v", "%1wː"},
{"(p[msɕ])", "%1ː"}, {"pr", "px"},
{"đn", "tnː"}, {"đr", "tx"}, {"đꬶv", "tkwː"},
{"b([sɕ])", "p%1"},
{"(ʦ[đlmn])", "%1ː"}, {"ʦꬶv", "ʦkwː"},
{"nꬶ", "ŋk"}, {"([ðđʦłɕꬶr])v", "%1wː"},
{"ʦxv", "ʦxw"}, {"đx", "tːx"},
{"đn", "tnː"}, {"đr", "tx"}, {"đꬶv", "tkwː"},
{"(ð[mꬶ])", "%1ː"},
{"(ʦ[đlmn])", "%1ː"}, {"ʦꬶv", "ʦkwː"},
{"ꝺx", "ðx"},
{"ʦxv", "ʦxw"}, {"đx", "tːx"},
{"(skl)", "%1ː"}, {"sʔk", "skː"}, {"sxv", "sxwː"},
{"(ð[mꬶ])", "%1ː"},
{"([lr])ʔ([ptk])", "%1%2ː"},
{"ꝺx", "ðx"},
{"lʦ(x?)v", "ɬʦ%1w"}, {"lʦx", "ɬʦx"},
{"(skl)", "%1ː"}, {"sʔk", "skː"}, {"sxv", "sxwː"},
{"(ł[mnꬶ])", "%1ː"},
{"([lr])ʔ([ptk])", "%1%2ː"},
{"(ꬶ[msɕ])", "%1ː"}, {"ꬶl", "ʔł", {"w"}}, {"ꬶl", "klː"},
{"lʦ(x?)v", "ɬʦ%1w"}, {"lʦx", "ɬʦx"},
{"ꬶsꬶ", "kskː"}, {"ꬶsl", "ksł"},
{"(ł[mnꬶ])", "%1ː"},
{"ɣ([mn])", "ŋ%1ː"}, {"ɣ([vsl])", "k%1"},
{"(ꬶ[msɕ])", "%1ː"}, {"ꬶl", "ʔł", {"w"}}, {"ꬶl", "klː"},
-- closed vowels
{"ꬶsꬶ", "kskː"}, {"ꬶsl", "ksł"},
{"(" .. vowel .. "*)(" .. consonant .. consonant .. ")", function(s1, s2) return open_to_closed(s1, w) .. s2 end, {"w"}},
{"ɣ([mn])", "ŋ%1ː"}, {"ɣ([vsl])", "k%1"},
{"(" .. vowel .. "*)(" .. consonant .. consonant .. ")", function(s1, s2) return open_to_closed(s1) .. s2 end},
{"(" .. vowel .. "*)(" .. consonant .. ")$", function(s1, s2) return open_to_closed(s1, w) .. s2 end, {"w"}},
{"(" .. vowel .. "*)(" .. consonant .. ")$", function(s1, s2) return open_to_closed(s1) .. s2 end},
{"ɑ$", "a"},
{"(" .. vowel .. ")đ$", "%1ʔ%1"}, -- -Vt becomes -VʔV (or -Vht, not considered)


-- closed vowels
--undo ligatures
{"(" .. vowel .. "*)(" .. consonant .. consonant .. ")", function(s1, s2) return open_to_closed(s1, w) .. s2 end, {"w"}},
{"ʨ", "t͡ɕ"}, {"ʥ", "d͡ʑ"}, {"ł", "tɬ"}, {"ʣ", "d͡z"}, {"ʦ", "t͡s"},
{"(" .. vowel .. "*)(" .. consonant .. consonant .. ")", function(s1, s2) return open_to_closed(s1) .. s2 end},
{"ƀ", "p"}, {"ꝺ", "d"}, {"đ", "t"}, {"ꬶ", "ɡ"}, {"ɉ", "ɟ"},
{"(" .. vowel .. "*)(" .. consonant .. ")$", function(s1, s2) return open_to_closed(s1, w) .. s2 end, {"w"}},
 
{"(" .. vowel .. "*)(" .. consonant .. ")$", function(s1, s2) return open_to_closed(s1) .. s2 end},
-- remove morpheme separator and possible double long vowel markers
{"ɑ$", "a"},
{"·", ""}, {"ːː", "ː"},
{"(" .. vowel .. ")đ$", "%1ʔ%1"}, -- -Vt becomes -VʔV (or -Vht, not considered)
}
--undo ligatures
{"ʨ", "t͡ɕ"}, {"ʥ", "d͡ʑ"}, {"ł", "tɬ"}, {"ʣ", "d͡z"}, {"ʦ", "t͡s"},
{"ƀ", "p"}, {"ꝺ", "d"}, {"đ", "t"}, {"ꬶ", "ɡ"}, {"ɉ", "ɟ"},
-- remove morpheme separator and possible double long vowel markers
{"·", ""}, {"ːː", "ː"},
}


function export.crux(term, e, w)
function export.crux(term, e, w)