Module:User:Santi2222/nv-pron

local export = {}

local m_script_utils = require("Module:script utilities") local U = mw.ustring.char local long = "ː" local nasal = U(0x0303) local high = U(0x0301) local low = U(0x0300) local desc = U(0x0302) local asc = U(0x030C)

-- single characters that map to IPA sounds (except vowels) (the characters h, l, m, n, w, x and z represent the same sound as in the IPA) local simple_char = {["ʼ"]="ʔ", ["b"]="p", ["d"]="t", ["g"]="k", ["j"]="t͡ʃ", ["k"]="kʰ", ["ł"]="ɬ", ["t"]="tʰ", ["y"]="j" } local three_char = {["chʼ"]="ñ͡ʃf", ["tłʼ"]="ñ͡ɬf", ["tsʼ"]="ñ͡sf", } local multiple_char = { ["ch"]="ñ͡ʃʰ", ["dl"]="ñˡ", ["dz"]="ñ͡s", ["gh"]="ɣ", ["hw"]="xʷ", ["kʼ"]="qf", ["kw"]="qʰʷ", ["sh"]="ʃ", ["tʼ"]="ñf", ["tł"]="ñ͡ɬʰ", ["ts"]="ñ͡sʰ", ["zh"]="ʒ"}--ñ and q substitute temporarily t and k.

local simple_oral = {["a"]="à", ["á"]="á", ["e"]="ɛ"..low, ["é"]="ɛ"..high, ["i"]="ɪ"..low, ["í"]="ɪ"..high, ["o"]="ò", ["ó"]="ó"} local multiple_oral = {["aa"]="àː", ["áá"]="áː", ["áa"]="âː", ["aá"]="ǎː", ["ee"]="зː", ["éé"]="бː", ["ée"]="вː", ["eé"]="дː", ["ii"]="ùː", ["íí"]="úː", ["íi"]="ûː", ["ií"]="ǔː", ["oo"]="òː", ["óó"]="óː", ["óo"]="ôː", ["oó"]="ǒː"}

local final_c = {["q"]="k", ["ñ"]="t", ["f"]="ʼ"}--undo the previous substitutions local final_v= {["ù"]="ì", ["ú"]="í", ["û"]="î", ["ǔ"]="ǐ", ["в"]="ê", ["д"]="ě", ["б"]="é", ["з"]="è"}--undo the previous substitutions

local simple_nasal = {["ą"]="ã"..low, ["ą"..high]="ã"..high, ["ę"]="ẽ"..low, ["ę"..high]="ẽ"..high, ["į"]="ĩ"..low, ["į"..high]="ĩ"..high, ["ǫ"]="õ"..low, ["ǫ"..high]="õ"..high} local multiple_nasal = { ["ąą"]="ã"..low..long, ["ą"..high.."ą"..high]="ã"..high..long, ["ą"..high.."a"]="ã"..desc..long, ["aą"..high]="ã"..asc..long, ["ęę"]="ẽ"..low..long, ["ę"..high.."ę"..high]="ẽ"..high..long, ["ę"..high.."e"]="ẽ"..desc..long, ["eę"..high]="ẽ"..asc..long, ["įį"]="ĩ"..low..long, ["į"..high.."į"..high]="ĩ"..high..long, ["į"..high.."i"]="ĩ"..desc..long, ["iį"..high]="ĩ"..asc..long, ["ǫǫ"]="õ"..low..long, ["ǫ"..high.."ǫ"..high]="õ"..high..long, ["ǫ"..high.."o"]="õ"..desc..long, ["oǫ"..high]="õ"..asc..long}

function export.pronunciation(word) if type(word) == "table" then word = word.args[1] or word:getParent.args[1] end if not word or (word == "") then error("Please put the word as the first positional parameter!") end word = mw.ustring.lower(word)

local phonetic = word

--initial glottal stop phonetic = mw.ustring.gsub(phonetic, " ([AÁaáEÉeéIÍiíOÓoóĄąĘęĮįǪǫ])", " ʔ%1") local sy = mw.text.split(phonetic, "") if mw.ustring.find(sy[1], "[AÁaáEÉeéIÍiíOÓoóĄąĘęĮįǪǫ]") then sy[1] = "ʔ"..sy[1] end phonetic = table.concat(sy,"") --vowels for pat, repl in pairs(multiple_oral) do		phonetic = mw.ustring.gsub(phonetic, pat, repl) end phonetic = mw.ustring.gsub(phonetic, '.', simple_oral) for pat, repl in pairs(multiple_nasal) do		phonetic = mw.ustring.gsub(phonetic, pat, repl) end phonetic = mw.ustring.gsub(phonetic, '.', simple_nasal) for pat, repl in pairs(final_v) do		phonetic = mw.ustring.gsub(phonetic, pat, repl) end --consonants for pat, repl in pairs(three_char) do		phonetic = mw.ustring.gsub(phonetic, pat, repl) end for pat, repl in pairs(multiple_char) do		phonetic = mw.ustring.gsub(phonetic, pat, repl) end phonetic = mw.ustring.gsub(phonetic, '.', simple_char) for pat, repl in pairs(final_c) do		phonetic = mw.ustring.gsub(phonetic, pat, repl) end --changes to the notation phonetic = mw.ustring.gsub(phonetic, 'á', "ɑ"..high) phonetic = mw.ustring.gsub(phonetic, 'à', "ɑ"..low) phonetic = mw.ustring.gsub(phonetic, 'â', "ɑ"..desc) phonetic = mw.ustring.gsub(phonetic, 'ǎ', "ɑ"..asc) phonetic = mw.ustring.gsub(phonetic, 'a', "ɑ") phonetic = mw.ustring.gsub(phonetic, 'ã', "ɑ"..nasal)

return phonetic end return export