Module:User:Thadh/ltg-IPA

local export={}

local m_IPA = require("Module:IPA") local lang = require("Module:languages").getByCode("ltg") local s = mw.upstring.gsub local title = mw.title.getCurrentTitle.text local palatalmark = u(0x02b2) local capital = { ["A"]="a", ["Ā"]="ā", ["B"]="b", ["C"]="c", ["Č"]="č", ["D"]="d", ["E"]="e", ["Ē"]="ē", ["F"]="f", ["G"]="g", ["Ģ"]="ģ", ["H"]="h", ["I"]="i", ["Ī"]="ī", ["J"]="j", ["K"]="k", ["Ķ"]="ķ", ["L"]="l", ["Ļ"]="ļ", ["M"]="m", ["N"]="n", ["Ņ"]="ņ", ["O"]="o", ["Ō"]="ō", ["P"]="p", ["R"]="r", ["S"]="s", ["Š"]="š", ["T"]="t", ["U"]="u", ["Ū"]="ū", ["V"]="v", ["Z"]="z", ["Ž"]="ž", ["Ẹ"]="ẹ", }; local charc = { ["a"]="a", ["ā"]="aː", ["b"]="b", ["c"]="t͡s", ["č"]="t͡ʃ", ["d"]="d", ["e"]="æ", ["ē"]="æː", ["f"]="f", ["g"]="ɡ", ["ģ"]="gʲ", ["h"]="x", ["i"]="i", ["ī"]="iː", ["j"]="j", ["k"]="k", ["ķ"]="kʲ", ["l"]="l", ["ļ"]="lʲ", ["m"]="m", ["n"]="n", ["ņ"]="nʲ", ["o"]="ɔ", ["ō"]="uɔ̯", ["p"]="p", ["r"]="r", ["s"]="s", ["š"]="ʃ", ["t"]="t", ["u"]="u", ["ū"]="uː", ["v"]="v", ["y"]="ɨ", ["z"]="z", ["ž"]="ʒ", ["ẹ"]="ɛ", ["-"]="", }; local const = { "p", "b", "t", "d", "k", "ɡ", "v", "s", "z", "t͡s", "d͡z" }; local prepvowel = "[æiɛ]" local postconst = "[ts]" local postnconst = { "p", "b", "d", "k", "g", "v", "z", "t͡s", "d͡z", "t͡ʃ", "d͡ʒ", "ʃ", "ʒ" }; local pconst = const .. palatalmark local alveol = { "ʃ", "ʒ", "t͡ʃ", "d͡ʒ" }; local digraph = { ["ie"]="iɛ̯", ["uo"]="uɔ̯", ["au"]="au̯", ["iu"]="iu̯", ["yu"]="ɨu̯", ["ou"]="ou̯", ["dž"]="d͡ʒ", ["ai"]="ai̯", ["ei"]="æi̯", ["oi"]="ɔi̯", ["ui"]="ui̯", ["ẹi"]="ɛi̯", }; local devoiced = { "p", "k", "t͡s","t͡ʃ", "ʃ", "t", "s", "f", }; local devoice = { ["b"]="p", ["bʲ"]="pʲ", ["d"]="t", ["dʲ"]="tʲ", ["g"]="k", ["gʲ"]="kʲ", ["d͡zʲ"]="t͡sʲ", ["v"]="f", ["vʲ"]="fʲ", ["z"]="s", ["zʲ"]="sʲ", ["ʒ"]="ʃ", ["d͡ʒ"]="t͡ʃ", ["d͡z"]="t͡s", }; local voiced = { "b", "g", "d͡z","d͡ʒ", "ʒ", "d", "z", "v", }; local voice = { ["p"]="b", ["pʲ"]="bʲ", ["t"]="d", ["tʲ"]="dʲ", ["k"]="g", ["kʲ"]="gʲ", ["t͡sʲ"]="d͡zʲ", ["f"]="v", ["fʲ"]="vʲ", ["s"]="z", ["sʲ"]="zʲ", ["ʃ"]="ʒ", ["t͡ʃ"]="d͡ʒ", ["t͡s"]="d͡z", };

function export.pronunciation_phonemic(word) word = s(word, ".", capital) -- converting capitals word = s(word, ".", digraph) -- converting digraphs word = s(word, ".", charc) -- converting regular consonants word = s(word, "(" .. const .. ")%f" .. prepvowel, "%1" .. palatalmark .. "%2") -- palatilsation followed by front vowel word = s(word, "(" .. const .. ")%f" .. pconst, "%1" .. palatalmark .. "%2") -- palatalisation followed by a palatal consonant word = s(word, "(" .. prepvowel .. postnconst .. "?" .. postnconst .. "?" .. postnconst .. "?" .. postnconst .. "?)%f" .. postconst, "%1" .. palatalmark .. "%2") word = s(word, "(" .. alveol .. ")%fæ", "%1ɛ") -- e is ɛ after an alveolar consonant word = s(word, "æ(" .. const .. "?" .. const .. "?" .. const .. "?" .. const .. "?" .. const .. "?)i", "ɛ%1i") -- e is ɛ before an i	word = s(word, ".$", devoice) -- final devoicing word = s(word, "%f" .. devoiced, devoice) -- final devoicing word = s(word, "%f" .. voiced, voice) -- pre-voiced voicing word = "/ˈ" .. word .. "/"	return word end

return export