Module:hsn-pron

Hello, you have come here looking for the meaning of the word Module:hsn-pron. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:hsn-pron, but we will also tell you about its etymology, its characteristics and you will know how to say Module:hsn-pron in singular and plural. Everything you need to know about the word Module:hsn-pron you have here. The definition of the word Module:hsn-pron will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:hsn-pron, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

Xiang Chinese pronunciation module. See {{zh-pron}} and Wiktionary:About Chinese/Xiang.


local m_str_utils = require("Module:string utilities")

local sub = m_str_utils.sub
local find = m_str_utils.find
local match = m_str_utils.match

local export = {}

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̠",  = "i̯a̠",  = "u̯a̠",  = "y̯a̠", 
	 = "o",  = "i̯o", 
	 = "ɤ̞",  = "u̯ɤ̞", 
	 = "ai̯",  = "u̯ai̯",  = "y̯ai̯", 
	 = "e̞i̯",  = "u̯e̞i̯",  = "y̯e̞i̯", 
	 = "ɒu̯",  = "i̯ɒu̯", 
	 = "əu̯",  = "i̯əu̯", 
	 = "i̯e̞",  = "y̯e̞", 
	 = "õ", 
	 = "ə̃",
	 = "i̯ẽ",  = "y̯ẽ",
	 = "ən",  = "u̯ən", 
	 = "in", 
	 = "yn", 
	 = "an",  = "i̯æn",  = "u̯an",  = "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
			if (find(initial, "^h$") and find(final, "^i")) or (find(initial, "^$") and find(final, "^")) or (find(final, "^r$") and not (initial == "" or find(initial, "^h?$"))) or (find(final, "^u") and not (initial == "" or find(initial, "^$"))) or (find(final, "^y") and not (initial == "" or initial == "ny" or find(initial, "^$"))) then
				error("Invalid input \"" .. syllable .. "\": initial " .. initial .. " cannot go with final " .. final .. ".")
			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("^") and
				match(final, "")) or final:match("^.*̃")) 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)
	return (text
		:gsub("/", " / ")
		:gsub("(+)", "<sup>%1</sup>"))
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