Module:hsn-pron-Hengyang
- පහත දැක්වෙන උපදෙස්, Module:hsn-pron-Hengyang/documentation හි පිහිටා ඇත. Module:hsn-pron-Hengyang/documentation]]. [සංස්කරණය]
- ප්රයෝජනවත් සබැඳි: උප පිටු ලැයිස්තුව • සබැඳි • transclusions • testcases • sandbox
Hengyang Xiang Chinese pronunciation module. See {{zh-pron}}
and Wiktionary:About Chinese/Xiang/Hengyang.
local export = {}
local m_string_utils = require("Module:string utilities")
local find = m_string_utils.find
local match = m_string_utils.match
local initialConv = {
["b"] = "p", ["p"] = "pʰ", ["bb"] = "b̥", ["m"] = "m", ["f"] = "f", ["v"] = "v̥",
["d"] = "t", ["t"] = "tʰ", ["dd"] = "d̥", ["n"] = "n", ["l"] = "l", ["ny"] = "n̠ʲ",
["z"] = "t͡s", ["c"] = "t͡sʰ", ["zz"] = "d̥͡z̥", ["s"] = "s", ["ss"] = "z̥",
["j"] = "t͡ɕ", ["q"] = "t͡ɕʰ", ["jj"] = "d̥͡ʑ̊", ["x"] = "ɕ", ["xx"] = "ʑ̊",
["g"] = "k", ["k"] = "kʰ", ["gg"] = "ɡ̊", ["ng"] = "ŋ",
["h"] = "x", ["gh"] = "ɣ̊", [""] = ""
}
local finalConv = {
["r"] = "z̩",
["i"] = "i", ["ui"] = "u̯ᵉi",
["u"] = "u", ["iu"] = "ɪ̯ᵒu̜˖",
["y"] = "y",
["a"] = "ä", ["ia"] = "ɪ̯ä", ["ua"] = "u̯ä", ["ya"] = "ʏ̯ä",
["e"] = "e", ["ie"] = "ɪ̯e̞", ["ue"] = "u̯e̞", ["ye"] = "ʏ̯e̞",
["o"] = "o̜", ["io"] = "ɪ̯o̹˔",
["er"] = "ə",
["ei"] = "eɪ̯", ["uei"] = "ᵘeɪ̯",
["ai"] = "aɪ̯", ["uai"] = "u̯aɪ̯",
["au"] = "ɑ̟ʊ̯͑", ["iau"] = "ɪ̯ɑ̟ʊ̯͑",
["ou"] = "ɘu̯",
["in"] = "ɪn", ["yn"] = "yn",
["ern"] = "ən", ["un"] = "u̯ən",
["en"] = "e̞n", ["ien"] = "ɪ̯ɛn", ["uen"] = "u̯ɛn", ["yen"] = "y̯ɛn",
["an"] = "an", ["ian"] = "ɪ̯an", ["uan"] = "u̯an",
["eng"] = "ɤ̟ŋ", ["ueng"] = "ᵘɤ̟ŋ",
["m"] = "m̩", ["ng"] = "ŋ̍"
}
local toneConv = {
["1"] = "⁴⁴⁵", ["2"] = "¹¹", ["3"] = "³³", ["4"] = "³²⁴", ["5"] = "²¹³", ["6"] = "²²",
["4*"] = "³²⁴⁻³¹", ["5*"] = "²¹³⁻³¹",
["0"] = "³",
}
function export.ipa(text)
if type(text) == "table" then
text = text.args[1]
end
local result = {}
for word in mw.text.gsplit(text, "/") do
local syllables = mw.text.split(word, " ")
local ipa = {}
for index, syllable in ipairs(syllables) do
local initial, final, tone
initial = syllable:match("^([bpmfdtlnzcsjqxgkh]?(g?))")
final = syllable:match("^" .. initial .. "([^1-6%*]*)")
if final == "" then
final = initial
initial = ""
end
if (find(initial, "^[zcs]$") and find(final, "^i")) or (find(initial, "^[jqx]$") and find(final, "^[aeou]")) or (find(final, "^r$") and not find(initial, "^[zcs]$")) then
error("Invalid input \"" .. syllable .. "\": initial " .. initial .. " cannot go with final " .. final .. ".")
end
tone = syllable:match("[1-6%*]+$") or "0"
if (match(initial, "^[bpm]$")) and (final == "ei" or final == "eng") then
final = "u" .. final
end
if (match(tone, "^[25]%*?") and match(initial, "^[bfdzsjxgh]$")) then
initial = initial:gsub("^[bfdzsqxkh]$", {
["b"] = "bb", ["f"] = "v", ["d"] = "dd", ["z"] = "zz", ["s"] = "ss",
["j"] = "jj", ["x"] = "xx", ["g"] = "gg", ["h"] = "gh",
})
end
if initial == "n" and (match(final, "^i")) then
initial = "ny"
end
initial = initialConv[initial] or error(("Unrecognised initial: \"%s\""):format(initial))
final = finalConv[final] or error(("Unrecognised final: \"%s\""):format(final))
tone = toneConv[tone] or error(("Unrecognised tone: \"%s\""):format(tone))
ipa[index] = initial .. final .. tone
end
local wordipa = table.concat(ipa, " ")
if not (find(word, "%d")) then
wordipa = wordipa:gsub("³", "")
end
table.insert(result, wordipa)
end
return table.concat(result, "/, /")
end
function export.rom(text)
return (text
:gsub("/", " / ")
:gsub("([%d-]+%*?)", "<sup>%1</sup>"))
end
return export