Module:hsn-pron-Hengyang

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

This module is experimental.
The details of its operation have not yet been fully decided upon. Do not deploy widely until the module is finished.

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 = {
	 = "p",  = "pʰ",  = "b̥",  = "m",  = "f",  = "v̥",
	 = "t",  = "tʰ",  = "d̥",  = "n",  = "l",  = "n̠ʲ",
	 = "t͡s",  = "t͡sʰ",  = "d̥͡z̥",  = "s",  = "z̥",
	 = "t͡ɕ",  = "t͡ɕʰ",  = "d̥͡ʑ̊",  = "ɕ",  = "ʑ̊",
	 = "k",  = "kʰ",  = "ɡ̊",  = "ŋ",
	 = "x",  = "ɣ̊",  = ""
}

local finalConv = {
	 = "z̩",
	 = "i",  = "u̯i",
	 = "u",  = "i̯u",
	 = "y", 
	 = "ä",  = "i̯ä",  = "u̯ä",  = "y̯ä",
	 = "e",  = "i̯e̞",  = "u̯e̞",  = "y̯e̞",
	 = "o",  = "i̯o",
	 = "ə",
	 = "ei̯",
	 = "ai̯",  = "u̯ai̯",
	 = "ɑʊ̯",  = "i̯ɑʊ̯",
	 = "ɘu̯",
	 = "in",  = "yn",
	 = "ən",  = "u̯ən",
	 = "e̞n",  = "i̯ɛn",  = "u̯ɛn",  = "y̯ɛn",
	 = "an",  = "i̯an",  = "u̯an",
	 = "ɤŋ",
	 = "m̩",  = "ŋ̍"
}

local toneConv = {
	 = "⁴⁴⁵",  = "¹¹",  = "³³",  = "³²⁴",  = "²¹³",  = "²²",
	 = "³²⁴⁻³¹",  = "²¹³⁻³¹",
	 = "³",
}

function export.ipa(text)
	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 = {}
		for index, syllable in ipairs(syllables) do
			local initial, final, tone
			initial = syllable:match("^(?(g?))")
			final = syllable:match("^" .. initial .. "(*)")
			if final == "" then
				final = initial
				initial = ""
			end
			if (find(initial, "^$") and find(final, "^i")) or (find(initial, "^$") and find(final, "^")) or (find(final, "^r$") and not find(initial, "^$")) then
				error("Invalid input \"" .. syllable .. "\": initial " .. initial .. " cannot go with final " .. final .. ".")
			end	
			tone = syllable:match("+$") or "0"
			if (match(tone, "^%*?") and match(initial, "^$")) then
				initial = initial:gsub("^$", {
					 = "bb",  = "v",  = "dd",  = "zz",  = "ss",
					 = "jj",  = "xx",  = "gg",  = "gh",
				})
			end
			if initial == "n" and (match(final, "^i")) then
				initial = "ny"
			end
			initial = initialConv or error(("Unrecognised initial: \"%s\""):format(initial))
			final = finalConv or error(("Unrecognised final: \"%s\""):format(final))
			tone = toneConv or error(("Unrecognised tone: \"%s\""):format(tone))
			ipa = 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("(+%*?)", "<sup>%1</sup>"))
end

return export