Module:cjy-pron

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

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


local export = {}
local m_string_utils = require("Module:string utilities")

local gsub = m_string_utils.gsub
local sub = mw.ustring.sub
local len = m_string_utils.len
local match = m_string_utils.match

local initialConv = {
	 = "p",  = "pʰ",  = "m",  = "f",  = "v",
	 = "t",  = "tʰ",  = "n",  = "l", 
	 = "t͡s",  = "t͡sʰ",  = "s",  = "ʐ",
	 = "t͡ɕ",  = "t͡ɕʰ",  = "ɕ",
	 = "k",  = "kʰ",  = "ɣ",  = "ŋ",
	 = "x",  = ""
}

local finalConv = {
	 = "z̩",
	 = "i",
	 = "u", 
	 = "y", 
	 = "əɻ", 
	 = "a",  = "ia",  = "ua", 
	 = "ɤ",  = "uɤ", 
	 = "ie",  = "ye", 
	 = "ai",  = "uai", 
	 = "ei",  = "uei", 
	 = "au",  = "iau", 
	 = "əu",  = "iəu", 
	 = "æ̃",  = "uæ̃",
	 = "ɒ̃",  = "iɒ̃",  = "uɒ̃",
	 = "aŋ",  = "iaŋ",  = "uaŋ", 
	 = "ə̃ŋ", 
	 = "ĩŋ", 
	 = "ũŋ", 
	 = "ỹŋ", 
	 = "aʔ",  = "iaʔ",  = "uaʔ", 
	 = "əʔ",  = "iəʔ",  = "uəʔ",  = "yəʔ",
	 = "z̩ɻ",
	 = "iɻ",
	 = "uɻ",
	 = "yɻ",
	 = "ɑɻ",  = "iɑɻ",  = "uɑɻ", 
	 = "ɤɻ",  = "uɤɻ", 
	 = "ieɻ",  = "yeɻ", 
	 = "ɐɻ",  = "uɐɻ", 
	 = "əɻ",  = "uəɻ", 
	 = "ɒoɻ",  = "iɒoɻ", 
	 = "əuɻ",  = "iəuɻ", 
	 = "æ̃ɻ",  = "uæ̃ɻ",
	 = "ɒ̃ɻ",  = "iɒ̃ɻ",  = "uɒ̃ɻ",
	 = "ʌ̃ɻ", 
	 = "ĩɻ", 
	 = "ũɻ", 
	 = "ỹɻ", 
	 = "ɐɻ",  = "iɐɻ",  = "uɐɻ", 
	 = "əɻ",  = "ieɻ",  = "uəɻ",  = "yeɻ",
}

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

local toneSandhi = {
	 = "2-1",  = "2-1",
	 = "4-5",  = "4-5",
	 = "4-3",  = "4-3",
	 = "5-4",  = "5-4",
}

local neutral = {
	 = "⁴",  = "³",  = "²"
}

function export.ipa(text, feature)
	if type(text) == "table" then
		text = text.args
	end
	local syllables, initial, final, tone, ipa, result = {}, {}, {}, {}, {}, {}
	local words = mw.text.split(text, "/")
	for _, word in ipairs(words) do
		syllables = mw.text.split(word, " ")
		for index, syllable in ipairs(syllables) do
			initial = match(syllable, "^??")
			final = match(sub(syllable, len(initial) + 1, -1), "^*")
			tone = match(syllable, "+$") or (index ~= 1 and "6" or "")
		end
		for index = 1, #syllables do
			initial = initialConv] or error(("Unrecognised initial: \"%s\""):format(initial))
			final = (match(initial, "") and final == "i") and "r" or final
			final = finalConv] or error(("Unrecognised final: \"%s\""):format(final))
			tone = tone == "6" and neutral] or tone
			tone = feature ~= "no_sandhi" and toneSandhi.."+"..(tone or "")] or tone
			tone = gsub(tone, "", toneConv)
			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

return export