User:Snowman304/Module:tk-IPA

local export = {}

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

local C = "[bçdfgğhjklmnprsştvyz]"           -- consonants local V = "[aeıioöuü]"                      -- vowels

local lowerc = { ["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", ["Y"]="y", ["Z"]="z" }

local phon = { -- consonants ["c"]="dʒ", ["ç"]="tʃ", ["ğ"]="ɰ", ["ş"]="ʃ", ["b"]="b", ["d"]="d", ["f"]="f", ["g"]="ɡ", ["h"]="h", ["j"]="ʒ", ["k"]="c", ["l"]="l", ["m"]="m", ["n"]="n", ["p"]="p", ["r"]="ɾ", ["s"]="s", ["t"]="t", ["v"]="v", ["y"]="j", ["z"]="z", -- vowels ["a"]="a", ["e"]="e", ["ı"]="ɯ", ["i"]="i", ["o"]="o", ["ö"]="œ", ["u"]="u", ["ü"]="y" }

local function phonemic(text) text = mw.ustring.gsub(text, '.', lowerc) -- general phonology text = mw.ustring.gsub(text, '.', phon) return text end

local function phonetic(text) text = mw.ustring.gsub(text, '.', lowerc) -- Adjustments for front vowels text = mw.ustring.gsub(text, "k([eiœyâû])", "c%1") text = mw.ustring.gsub(text, "g([eiœyâû])", "ɟ%1") -- Adjustments for other vowels text = mw.ustring.gsub(text, "l([aɯou])", "ɫ%1") -- Adjustments for ɰ text = mw.ustring.gsub(text, "(["..V.."])ɰ$", "%1ː")     -- Word-finally text = mw.ustring.gsub(text, "(["..V.."])ɰ(["..C.."])", "%1ː%2") -- Preconsonantally text = mw.ustring.gsub(text, "([eiœy])ɰ([eiœy])", "%1ɰ̟%2")   -- Between front vowels text = mw.ustring.gsub(text, "(["..V.."])ɰ(["..V.."])", "%1%2") -- Otherwise, delete -- Place of articulation adjustments text = mw.ustring.gsub(text, "n", "n̪") text = mw.ustring.gsub(text, "t", "t̪") text = mw.ustring.gsub(text, "d", "d̪") text = mw.ustring.gsub(text, "s", "s̪") text = mw.ustring.gsub(text, "z", "z̪") text = mw.ustring.gsub(text, "ɫ", "ɫ̪") text = mw.ustring.gsub(text, "l", "l̠ʲ") -- Devoice and modify /ɾ/ text = mw.ustring.gsub(text, "ɾ(["..C.."]?)$", "ɾ̞̊%1") text = mw.ustring.gsub(text, "^ɾ", "ɾ̞") text = mw.ustring.gsub(text, "ɾ(["..C.."^aeıioöuü])", function(s) 		return s == "" and "ɾ̞̊" or (s:find("[ptck]") and "ɾ̞̊" or "ɾ")	end) -- Voiceless /ɫ/ and /l/ text = mw.ustring.gsub(text, "[ɫl](["..C.."^aeıioöuü]?)$", function(s)		return s:find("[ptck]") and "ɫ̞̊" or "ɫ̞"	end) -- Aspirate syllable-initial p, t, c, k	text = mw.ustring.gsub(text, "^([ptck])", "%1ʰ") text = mw.ustring.gsub(text, " (["..V.."]?)([ptck])", " %1%2ʰ") -- Fronting of final /h/ text = mw.ustring.gsub(text, "h$", "x") text = mw.ustring.gsub(text, "h([eiœy])", "ç%1") -- Devoicing of /b, d, d͡ʒ, ɡ, ɟ/ text = mw.ustring.gsub(text, "[bdɟ]$", "p") text = mw.ustring.gsub(text, "d͡ʒ$", "t͡ʃ") text = mw.ustring.gsub(text, "ɡ$", "k") text = mw.ustring.gsub(text, "([bdɟd͡ʒɡ])["..C.."^aeıioöuü]?", function(s)		local map = { b="p", d="t", ɟ="c", ["d͡ʒ"]="t͡ʃ", ɡ="k" }		return map[s]	end) -- Flash forward to phonemic transcription text = phonemic(text) 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, IPA_results) end

return export