Module:User:Snowman304/tt-IPA

local export = {}

local m_IPA = require("Module:IPA") local lang = require("Module:languages").getByCode("tt")

local C = "[бвгғджҗзйкқлмнңпрстфхһцчшщъь]" -- consonants local V = "[аәеёиоөуүыэюя]" -- vowels

local lowerc = { ["А"]="а", ["Ә"]="ә", ["Б"]="б", ["В"]="в", ["Г"]="г", ["Ғ"]="ғ", ["Д"]="д", ["Е"]="е", ["Ё"]="ё", ["Ж"]="ж", ["Җ"]="җ", ["З"]="з", ["И"]="и", ["Й"]="й", ["К"]="к", ["Қ"]="қ", ["Л"]="л", ["М"]="м", ["Н"]="н", ["Ң"]="ң", ["О"]="о", ["Ө"]="ө", ["П"]="п", ["Р"]="р", ["С"]="с", ["Т"]="т", ["У"]="у", ["Ү"]="ү", ["Ф"]="ф", ["Х"]="х", ["Һ"]="һ", ["Ц"]="ц", ["Ш"]="ш", ["Щ"]="щ", ["Ъ"]="ъ", ["Ы"]="ы", ["Ь"]="ь", ["Э"]="э", ["Ю"]="ю", ["Я"]="я" }

local phon = { -- Modify this list based on Tatar-specific phonetic transcriptions ["ый"]="ɯɪ", ["а"]="ɑ", ["ә"]="æ", ["б"]="b", ["в"]="w", ["г"]="g", ["ғ"]="ʁ", ["д"]="d", ["е"]="ĕ", ["ё"]=jo"", ["ж"]="ʒ", ["җ"]="ʑ", ["з"]="z", ["и"]="i", ["й"]="j", ["к"]="k", ["қ"]="q", ["л"]="l", ["м"]="m", ["н"]="n", ["ң"]="ŋ", ["о"]="ŏ", ["ө"]="ø̆", ["п"]="p", ["р"]="r", ["с"]="s", ["т"]="t", ["у"]="u", ["ү"]="y", ["ф"]="f", ["х"]="χ", ["һ"]="h", ["ц"]="t͡s", ["ш"]="ʃ", ["щ"]="ʃɕ", ["ъ"]="ʔ", ["ы"]="ɤ̆", ["ь"]="ʔ", ["э"]="e", ["ю"]="ju", ["я"]="jɑ" }

local function phonemic(text) -- ... (your Tatar phonemic rules) return text end

local function phonetic(text) -- Allophonic rules for /q/ and /ʁ/ -- /k/ becomes /q/ before back vowels text = mw.ustring.gsub(text, "к([аоуыэ])", "q%1") -- /ɡ/ becomes /ʁ/ before back vowels text = mw.ustring.gsub(text, "г([аоуыэ])", "ʁ%1") -- For loanwords: къ and гъ remain /q/ and /ʁ/ respectively text = mw.ustring.gsub(text, "къ", "q") text = mw.ustring.gsub(text, "гъ", "ʁ") -- Rule for rounding vowels after o or ө, sometimes with an intervening consonant text = mw.ustring.gsub(text, "о([бвгғджҗзйкқлмнңпрстфхһцчшщъь]*)ы", "о%1у") text = mw.ustring.gsub(text, "ө([бвгғджҗзйкқлмнңпрстфхһцчшщъь]*)ы", "ө%1у") text = mw.ustring.gsub(text, "о([бвгғджҗзйкқлмнңпрстфхһцчшщъь]*)е", "о%1ө") text = mw.ustring.gsub(text, "ө([бвгғджҗзйкқлмнңпрстфхһцчшщъь]*)е", "ө%1ө") -- Nasal assimilation text = mw.ustring.gsub(text, "[мнң]([пб])", "м%1") text = mw.ustring.gsub(text, "[мнң]([тд])", "н%1") text = mw.ustring.gsub(text, "[мнң]([кг])", "н%1") return text end

function export.IPA(frame) local words = {}

for _, word in ipairs(frame:getParent.args) do		table.insert(words, word) end

if #words == 0 then words = {mw.title.getCurrentTitle.text} end

local IPA_results = {}

for _, word in ipairs(words) do table.insert(IPA_results, { pron = "/" .. phonemic(word) .. "/" }) table.insert(IPA_results, { pron = "[" .. phonetic(word) .. "]" }) end

return m_IPA.format_IPA_full { lang = lang, items = IPA_results } end

return export