Module:hsn-pron-Loudi

Hello, you have come here looking for the meaning of the word Module:hsn-pron-Loudi. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:hsn-pron-Loudi, but we will also tell you about its etymology, its characteristics and you will know how to say Module:hsn-pron-Loudi in singular and plural. Everything you need to know about the word Module:hsn-pron-Loudi you have here. The definition of the word Module:hsn-pron-Loudi will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:hsn-pron-Loudi, 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.

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


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",
	 = "t",  = "tʰ",  = "d",  = "n",   = "l", 
	 = "t͡s",  = "t͡sʰ",  = "d͡z",  = "s",
	 = "t͡ɕ",  = "t͡ɕʰ",  = "d͡ʑ",  = "ɕ",  = "ʑ",
	 = "k",  = "kʰ",  = "ŋ",
	 = "x",  = "ɣ",  = ""
}

local finalConv = {
	 = "z̩",
	 = "i",  = "u̯i",  = "y̯i",
	 = "u",  = "ɤu̯",
	 = "y", 
	 = "a̠",  = "i̯a",  = "u̯a",
	 = "e̞",  = "i̯e̞",  = "u̯e̞",  = "y̯e̞", 
	 = "ɔ",  = "i̯ɔ", 
	 = "ʊ",  = "i̯ʊ", 
	 = "ɤ",  = "i̯ɤ",
	 = "in",  = "un",  = "yn",
	 = "ɔŋ",  = "i̯ɔŋ",  = "u̯ɔŋ",
	 = "ɤŋ",  = "i̯ɤŋ",  = "u̯ɤŋ",
	 = "ã̠",  = "u̯ã",
	 = "ẽ̞",  = "u̯ẽ̞",
	 = "ɔ̃",  = "i̯ɔ̃", 
	 = "ĩ",  = "u̯ĩ",  = "yĩ",
	 = "m̩",  = "n̩",  = "ŋ̍"
}

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
			local initial_orig = nil
			initial = syllable:match("^(?(?))")
			final = syllable:match("^" .. initial .. "(*)")
			if final == "" then
				final = initial
				initial = ""
			end
			if (find(final, "^r$") and not find(initial, "^z?$")) or (find(initial, "^?$") and find(final, "^")) or (find(final, "") and initial == "l") then
				error("Invalid input \"" .. syllable .. "\": initial " .. initial .. " cannot go with final " .. final .. ".")
			end	
			tone = syllable:match("+$") or "0"
			if (match(initial, "?")) and final == "u" then
				final = "euu"
			end
			if (match(tone, "%*") and match(initial, "^$")) then
				initial_orig = initialConv
				initial = initial:gsub("^$", {  = "zz",  = "zz",  = "jj",  = "jj", })
			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_orig and ("<sup>(" .. initial_orig .. "-)</sup>") or "") .. 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