မဝ်ဂျူ:sds-IPA
မံက်ပြာကတ်
local export = {}
local m_q = require("Module:qualifier")
local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("sds")
local rsubn = mw.ustring.gsub
local function rsub(term, foo, bar)
local retval = rsubn(term, foo, bar)
return retval
end
local function rsub_repeatedly(term, foo, bar)
while true do
local new_term = rsub(term, foo, bar)
if new_term == term then
return term
end
term = new_term
end
end
-- single characters that map to IPA sounds
local phonetic_chars_map = {
["'"] = "ʔ",
["g"] = "ɡ",
["ǧ"] = "d͡ʒ",
["ḍ"] = "dˤ",
["e"] = "ə",
["h"] = "ɦ",
["ḥ"] = "ħ",
["ɛ"] = "ʕ",
["x"] = "χ",
["I"] = "i",
["j"] = "ʒ",
["K"] = "k",
["L"] = "l",
["M"] = "m",
["ṛ"] = "rˤ",
["Ṛ"] = "rˤ",
["ḷ"] = "lˤ",
["ṣ"] = "sˤ",
["T"] = "tˤ",
["c"] = "ʃ",
["č"] = "t͡ʃ",
["ṭ"] = "tˤ",
["y"] = "J",
["Y"] = "J",
["ẓ"] = "zˤ",
["ʷ"] = "ʷ",
["ɣ"] = "ʁ",
}
function export.sds_IPA(text, variant, do_debug)
text = rsub_repeatedly(text, "(.)%1", "%1ː")
text = rsub_repeatedly(text, '.', phonetic_chars_map)
text = rsub_repeatedly(text, "J", "j")
return text
end
function export.show(frame)
local args = frame:getParent().args
local pagetitle = mw.loadData("Module:headword/data").pagename
local p, results = {}, {}
if args[1] then
for index, item in ipairs(args) do
table.insert(p, (item ~= "") and item or nil)
end
else
p = { pagetitle }
end
for _, word in ipairs(p) do
table.insert(results, { pron = "/" .. export.sds_IPA(word) .. "/" })
end
return m_IPA.format_IPA_full { lang = lang, items = results }
end
return export