Module:tpw-IPA

local export = {} local PAGENAME = mw.title.getCurrentTitle.text

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

-- single characters that map to IPA sounds local phonetic_chars_map = { ["b"] = "β̞", ["h"] = "h", ["k"] = "k", ["m"] = "m", ["n"] = "n", ["p"] = "p", ["r"] = "ɾ", ["s"] = "s", ["t"] = "t", ["x"] = "ʃ", ["w"] = "w", ["a"] = "a", ["e"] = "ɛ", ["i"] = "i", ["o"] = "ɔ", ["u"] = "u", ["y"] = "ɨ", ["ã"] = "ã", ["ẽ"] = "ɛ̃", ["ĩ"] = "ĩ", ["õ"] = "ɔ̃", ["ũ"] = "ũ", ["ỹ"] = "ɨ̃", ["î"] = "j", ["û"] = "w", ["ŷ"] = "ɨ̯", ["'"] = "ʔ", }

-- character sequences of two that map to IPA sounds local phonetic_2chars_map = { ["gû"] = "ɡʷ", ["kû"] = "kʷ", ["mb"] = "ᵐb", ["nd"] = "ⁿd", ["ng"] = "ŋ", ["nh"] = "ɲ", ["pî"] = "pʲ", ["pû"] = "pʷ", ["yg"] = "ɨɣ", }

function export.to_IPA(word) word = mw.ustring.lower(word)

local phonetic = word

for pat, repl in pairs(phonetic_2chars_map) do		phonetic = phonetic:gsub(pat, repl) end

phonetic = mw.ustring.gsub(phonetic, '.', phonetic_chars_map)

-- FIX ME: nasalisation before M and N -- --	phonetic = mw.ustring.gsub(phonetic, "([aɛiɔuɨ])n", "%1n") -> turns into ãn, ɛ̃n etc. --	phonetic = mw.ustring.gsub(phonetic, "([aɛiɔuɨ)m", "%1m")

return "[" .. phonetic .. "]" end

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 word = PAGENAME end local items = {} table.insert(items, {pron = export.to_IPA(word), note = nil}) return m_IPA.format_IPA_full { lang = lang, items = items } end

return export