Module:X-SAMPA to IPA
Appearance
local p = {}
local U = mw.ustring.char
local gsub = mw.ustring.gsub
local data = {
["a"] = { "a" },
["b"] = { "b" },
["b_<"] = { "ɓ" },
["c"] = { "c" },
["d"] = { "d" },
["d`"] = { "ɖ", descender = true },
["d_<"] = { "ɗ" },
["e"] = { "e" },
["f"] = { "f" },
["g"] = { "ɡ", descender = true },
["g_<"] = { "ɠ", descender = true },
["h"] = { "h" },
["h\\"] = { "ɦ" },
["i"] = { "i" },
["j"] = { "j", descender = true },
["j\\"] = { "ʝ", descender = true },
["k"] = { "k" },
["l"] = { "l" },
["l`"] = { "ɭ", descender = true },
["l\\"] = { "ɺ" },
["m"] = { "m" },
["n"] = { "n" },
["n`"] = { "ɳ", descender = true },
["o"] = { "o" },
["p"] = { "p", descender = true },
["p\\"] = { "ɸ", descender = true },
["q"] = { "q", descender = true },
["r"] = { "r" },
["r`"] = { "ɽ", descender = true },
["r\\"] = { "ɹ" },
["r\\`"] = { "ɻ", descender = true },
["s"] = { "s" },
["s`"] = { "ʂ", descender = true },
["s\\"] = { "ɕ" },
["t"] = { "t" },
["t`"] = { "ʈ" },
["u"] = { "u" },
["v"] = { "v" },
["v\\"] = { "ʋ" },
["w"] = { "w" },
["x"] = { "x" },
["x\\"] = { "ɧ", descender = true },
["y"] = { "y", descender = true },
["z"] = { "z" },
["z`"] = { "ʐ", descender = true },
["z\\"] = { "ʑ" },
["A"] = { "ɑ" },
["B"] = { "β", descender = true },
["B\\"] = { "ʙ" },
["C"] = { "ç", descender = true },
["D"] = { "ð" },
["E"] = { "ɛ" },
["F"] = { "ɱ", descender = true },
["G"] = { "ɣ", descender = true },
["G\\"] = { "ɢ" },
["G\\_<"] = { "ʛ" },
["H"] = { "ɥ", descender = true },
["H\\"] = { "ʜ" },
["I"] = { "ɪ" },
["I\\"] = { "ɪ̈" },
["J"] = { "ɲ", descender = true },
["J\\"] = { "ɟ" },
["J\\_<"] = { "ʄ", descender = true },
["K"] = { "ɬ" },
["K\\"] = { "ɮ", descender = true },
["L"] = { "ʎ" },
["L\\"] = { "ʟ" },
["M"] = { "ɯ" },
["M\\"] = { "ɰ", descender = true },
["N"] = { "ŋ", descender = true },
["N\\"] = { "ɴ" },
["O"] = { "ɔ" },
["O\\"] = { "ʘ" },
["P"] = { "ʋ" },
["Q"] = { "ɒ" },
["R"] = { "ʁ" },
["R\\"] = { "ʀ" },
["S"] = { "ʃ", descender = true },
["T"] = { "θ" },
["U"] = { "ʊ" },
["U\\"] = { "ʊ̈" },
["V"] = { "ʌ" },
["W"] = { "ʍ" },
["X"] = { "χ", descender = true },
["X\\"] = { "ħ" },
["Y"] = { "ʏ" },
["Z"] = { "ʒ", descender = true },
["."] = { "." },
["\""] = { "ˈ" },
["%%"] = { "ˌ" },
["'"] = { "ʲ", diacritic = true },
[":"] = { "ː", diacritic = true },
[":\\"] = { "ˑ", diacritic = true },
["@"] = { "ə" },
["@\\"] = { "ɘ" },
["{"] = { "æ" },
["}"] = { "ʉ" },
["1"] = { "ɨ" },
["2"] = { "ø" },
["3"] = { "ɜ" },
["3\\"] = { "ɞ" },
["4"] = { "ɾ" },
["5"] = { "ɫ" },
["6"] = { "ɐ" },
["7"] = { "ɤ" },
["8"] = { "ɵ" },
["9"] = { "œ" },
["&"] = { "ɶ" },
["%?"] = { "ʔ" },
["%?\\"] = { "ʕ" },
["<\\"] = { "ʢ" },
[">\\"] = { "ʡ" },
["^"] = { "ꜛ" },
["!"] = { "ꜜ" },
["!\\"] = { "ǃ" },
["|"] = { "|", descender = true },
["|\\"] = { "ǀ", descender = true },
["||"] = { "‖", descender = true },
["|\\|\\"] = { "ǁ", descender = true },
["=\\"] = { "ǂ", descender = true },
["%-\\"] = { "‿", diacritic = true },
["_\""] = { U(0x308), diacritic = true },
["_+"] = { U(0x31F), descender = "˖", diacritic = true },
["_-"] = { U(0x320), descender = "˗", diacritic = true },
["_/"] = { U(0x30C), diacritic = true },
["_0"] = { U(0x325), descender = U(0x30A), diacritic = true },
["="] = { U(0x329), descender = U(0x30D), diacritic = true },
["_="] = { U(0x329), descender = U(0x30D), diacritic = true },
["_>"] = { "ʼ", diacritic = true },
["_?\\"] = { "ˤ", diacritic = true },
["_\\"] = { U(0x302), diacritic = true },
["_^"] = { U(0x32F), descender = U(0x311), diacritic = true },
["_}"] = { U(0x31A), diacritic = true },
["`"] = { U(0x2DE), diacritic = true },
["~"] = { U(0x303), diacritic = true },
["_A"] = { U(0x318), diacritic = true },
["_a"] = { U(0x33A), diacritic = true },
["_B"] = { U(0x30F), diacritic = true },
["_B_L"] = { U(0x1DC5), diacritic = true },
["_c"] = { U(0x31C), diacritic = true },
["_d"] = { U(0x32A), diacritic = true },
["_e"] = { U(0x334), diacritic = true },
["<F>"] = { "↘" },
["_F"] = { U(0x302), diacritic = true },
["_G"] = { "ˠ", diacritic = true },
["_H"] = { U(0x301), diacritic = true },
["_H_T"] = { U(0x1DC4), diacritic = true },
["_h"] = { "ʰ", diacritic = true },
["_j"] = { "ʲ", diacritic = true },
["_k"] = { U(0x330), diacritic = true },
["_L"] = { U(0x300), diacritic = true },
["_l"] = { "ˡ", diacritic = true },
["_M"] = { U(0x304), diacritic = true },
["_m"] = { U(0x33B), diacritic = true },
["_N"] = { U(0x33C), diacritic = true },
["_n"] = { "ⁿ", diacritic = true },
["_O"] = { U(0x339), diacritic = true },
["_o"] = { U(0x31E), descender = "˕", diacritic = true },
["_q"] = { U(0x319), diacritic = true },
["<R>"] = { "↗" },
["_R"] = { U(0x30C), diacritic = true },
["_R_F"] = { U(0x1DC8), diacritic = true },
["_r"] = { U(0x31D), diacritic = true },
["_T"] = { U(0x30B), diacritic = true },
["_t"] = { U(0x324), diacritic = true },
["_v"] = { U(0x32C), diacritic = true },
["_w"] = { "ʷ", diacritic = true },
["_X"] = { U(0x306), diacritic = true },
["_x"] = { U(0x33D), diacritic = true },
}
local function _X2IPA(text)
for XSAMPA, IPA in pairs(data) do
text = gsub(text, XSAMPA, IPA)
end
return text
end
function p.X2IPA(frame)
local args = frame.args
local text = args[1]
output = {}
table.insert(output, "<span class=\"IPA\">")
table.insert(output, _X2IPA(text))
table.insert(output, "</span>")
return table.concat(output)
end
return p