A modult a Modul:hsn-pron/doc lapon tudod dokumentálni
local export = {}
local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local len = mw.ustring.len
local match = mw.ustring.match
local initialConv = {
= "p", = "pʰ", = "m", = "ɸ",
= "t", = "tʰ", = "l",
= "t͡s", = "t͡sʰ", = "s",
= "ʈ͡ʂ", = "ʈ͡ʂʰ", = "ʂ", = "ʐ",
= "t͡ɕ", = "t͡ɕʰ", = "ɕ", = "n̠ʲ",
= "k", = "kʰ", = "ŋ",
= "x", = ""
}
local finalConv = {
= "z̩", = "ʐ̩",
= "i",
= "u",
= "y",
= "a̠", = "ia̠", = "ua̠", = "ya̠",
= "o", = "io",
= "ɤ̞", = "uɤ̞",
= "ai", = "uai", = "yai",
= "e̞i", = "ue̞i", = "ye̞i",
= "ɒu", = "iɒu",
= "əu", = "iəu",
= "ie̞", = "ye̞",
= "õ",
= "ə̃",
= "iẽ", = "yẽ",
= "ən", = "uən",
= "in",
= "yn",
= "an", = "iæn", = "uan", = "yæn",
= "ʊŋ", = "iʊŋ",
= "m̩",
= "n̩",
}
local toneConv = {
= "³³", = "¹³", = "⁴¹", = "⁴⁵", = "²¹", = "²⁴", = "³",
= "²¹⁻¹¹", = "²⁴⁻⁴⁴", = "²⁴⁻²²", = "²⁴", = ""
}
function export.ipa(text, style)
if type(text) == "table" then
text = text.args
end
local result = {}
for word in mw.text.gsplit(text, "/") do
local syllables = mw.text.split(word, " ")
local ipa, tone = {}, {}
for index, syllable in ipairs(syllables) do
local initial, final
initial = syllable:match("^(?(?))")
if initial:match("^.y") and initial ~= "ny" then
initial = sub(initial, 1, 1)
elseif initial == "y" then
initial = ""
end
final = syllable:match("^" .. initial .. "(*)")
if final == "" then
final = initial
initial = ""
end
tone = syllable:match("+$") or (index ~= 1 and "7" or "")
if style == "new" then
initial = initial:gsub("()h", "%1")
if final:match("^i") then
initial = initial:gsub("$", { = "j", = "q", = "x" })
end
final = final:gsub("(i?ong)", { = "in", = "en" })
end
initial = initialConv or error(("Unrecognised initial: \"%s\""):format(initial))
if (initial == "" or match(initial, "")) and final == "r" then
final = "rr"
end
final = finalConv or error(("Unrecognised final: \"%s\""):format(final))
if initial == "l" and ((final ~= "ən" and not final:match("^i") and
match(final, "")) or final:match("^i.*̃")) then
initial = "l̃"
end
if tone == "5" and #syllables > 1 then
tone = "5-ts"
elseif tone == "6" then
if match(tone or "", "") then
tone = "6-high"
elseif match(tone or "", "") then
tone = "6-low"
end
end
tone = toneConv] or error(("Unrecognised tone: \"%s\""):format(tone))
ipa = initial .. final .. tone
end
table.insert(result, table.concat(ipa, " "))
end
return table.concat(result, "/, /")
end
function export.rom(text)
text = gsub(text, "/", " / ")
text = gsub(text, '(+)', '<sup>%1</sup>')
return text
end
function export.stylediff(text)
if match(text, "h") or match(text, "i") or match(text, "i?ong") then
return true
end
return false
end
return export