Used by {{ane-IPA}}
.
local export = {}
local PAGENAME = mw.title.getCurrentTitle().text
local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("ane")
-- single characters that map to IPA sounds
local phonetic_chars_map = {
= "ɑ",
= "ʌ̃",
= "ɑ̃",
= "ᵐb",
= "t͡ʃ",
= "ⁿd",
= "ɤ",
= "e",
= "ʌ",
= "ɛ",
= "ɛ̃",
= "f",
= "ᵑɡ",
= "i",
= "ĩ",
= "ᶮɟ",
= "k",
= "l",
= "m",
= "n",
= "o",
= "ɔ",
= "ɔ̃",
= "p",
= "r",
= "ç",
= "t",
= "u",
= "ɨ̃",
= "ɨ",
= "ũ",
= "v",
= "w",
= "x",
= "j",
}
-- character sequences of two that map to IPA sounds
local phonetic_2chars_map = {
= "ɑː",
= "ʌ̃ː",
= "ɑ̃ː",
= "ᵐbʷ",
= "ʃ",
= "ɤː",
= "eː",
= "ʌː",
= "ɛː",
= "ɛ̃ː",
= "ᵑɡʷ",
= "iː",
= "ĩː",
= "kʷ",
= "mʷ",
= "ŋ",
= "ɲ",
= "oː",
= "ɔː",
= "ɔ̃ː",
= "pʷ",
= "uː",
= "ɨ̃ː",
= "ɨː",
= "ũː",
= "xʷ",
}
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)
return ""
end
function export.pronunciation(word)
if type(word) == "table" then
word = word.args or word:getParent().args
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