Module:User:Snowman304/ht-IPA

local export = {}

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

local phon = { ["ui"] = "ɥi", ["ch"] = "ʃ", ["ou"] = "u", ["ng"] = "ŋ", ["èn"] = "ệ", ["òn"] = "ộ", ["àn"] = "ậ", -- temporary placeholders ["en"] = "ẹ", ["on"] = "ọ", ["an"] = "ạ",     -- placeholders for nasal vowels ["a"] = "a", ["b"] = "b", ["d"] = "d", ["y"] = "ý", ["e"] = "e", ["è"] = "ɛ", ["f"] = "f", ["g"] = "ɡ", ["h"] = "h", ["i"] = "i", ["j"] = "ʒ", ["k"] = "k", ["l"] = "l", ["m"] = "m", ["n"] = "n", ["o"] = "o", ["ò"] = "ɔ", ["p"] = "p", ["r"] = "ɣ", ["s"] = "s", ["t"] = "t", ["v"] = "v", ["w"] = "w", ["z"] = "z", ["x"] = "ks" }

local exceptions = { ["houngan"] = "ũɡã", ["ounsi"] = "ũsi", ["ounfo"] = "ũfɔ", ["houn"] = "hũ", ["ogoun"] = "oɡũ", ["oungève"] = "ũɡɛvɛ", ["bounda"] = "bũda", ["pinga"] = "pĩɡa", ["kachinbo"] = "kaʃĩbo", ["youn"] = "jũ", ["oun neg"] = "ũ nɛɡ" }

local function phonemic(text) -- Convert text to lowercase text = mw.ustring.lower(text)

-- Handle exceptions first if exceptions[text] then return exceptions[text] end

-- Handle multigraph sequences for multigraph, value in pairs(phon) do       text = mw.ustring.gsub(text, multigraph, value) end

-- Revert the nasalized vowels from placeholders to actual IPA symbols text = mw.ustring.gsub(text, "ệ", "ɛn") text = mw.ustring.gsub(text, "ộ", "ɔn") text = mw.ustring.gsub(text, "ậ", "an") text = mw.ustring.gsub(text, "ẹ", "ɛ̃") text = mw.ustring.gsub(text, "ọ", "ɔ̃") text = mw.ustring.gsub(text, "ạ", "ã") text = mw.ustring.gsub(text, "ý", "j") 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) .. "/" }) end

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

return export