Module:qinlian-pron

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

local export = {}

local ugsub = mw.ustring.gsub
local split = mw.text.split

local entering_tones = {
	 = "7",  = "8",  = "9"
}

local ipa_preprocess = {
	 = {"a", "ă"},  = {"yu", "y"},  = {"ăă", "a"},  = {"uk", "ŭk"},  = {"ik", "ĭk"},
	 = {"ou", "ŏu"},  = {"eoi", "eoy"},  = {"ung", "ŭng"},  = {"ing", "ĭng"},  = {"ei", "ĕi"},
	 = {"oi", "oy"},  = {"ui", "uy"}
}

local ipa_initial = {
	 = "p",  = "pʰ",  = "m",  = "f", 
	 = "t",  = "tʰ",  = "n",  = "l",  = "ɬ",  = "ɲ̟",
	 = "k",  = "kʰ",  = "ŋ",  = "kʷ",  = "kʷʰ",
	 = "t͡ʃ",  = "t͡ʃʰ",  = "ʃ",
	 = "t͡s",  = "t͡sʰ",  = "s", 
	 = "h",  = "w",  = "j", 
	 = ""
}

local ipa_nucleus = {
	 = "ä",  = "ɐ", 
	 = "ɛ",  = "e", 
	 = "i",  = "ɪ", 
	 = "ɔ",  = "o", 
	 = "œ",  = "ɵ", 
	 = "u",  = "ʊ", 
	 = "yː"
}

local ipa_coda = {
	 = "i̯",  = "u̯",  = "y̯", 
	 = "m",  = "n",  = "ŋ", 
	 = "p̚",  = "t̚̚", 
	 = "",
}

local ipa_tone = {
	 = "⁴⁵", 
	 = "²⁴", 
	 = "³³", 
	 = "<span style=\"cursor:help\" title=\"or 11\">²²</span>"
}

local ipa_tone_sandhi = {
	 = "⁻",  = "⁻",  = ""
}

local ipa_syllabic = {
	 = "m̩",  = "ŋ̍"
}

local acute_accents = {
	 = "á",  = "é",  = "í",  = "ó",  = "ú"
}

local grave_accents = {
	 = "à",  = "è",  = "ì",  = "ò",  = "ù"
}

local macrons = {
	 = "ā",  = "ē",  = "ī",  = "ō",  = "ū"
}

local yale_final = {
	 = "a",  = "沒有耶魯拼音",  = "沒有耶魯拼音",  = "沒有耶魯拼音",  = "沒有耶魯拼音",
	 = "eu",  = "eung",  = "euk",  = "eui",  = "eun",  = "eut",
	 = ""
}

local canton_pinyin_regex = {
	 = "y",  = "oe",  = "oey",  = "dz%1",  = "ts%1",
	)()"]=function(a,b) return a .. entering_tones end,
	)()$"]=function(a,b) return a .. entering_tones end
}

local function yale_tone(final,b)
	if b == "4" or b == "5" or b == "6" then
		final = final:gsub("(?g?)$", "h%1", 1)
	end
	if b == "1" then final = final:gsub("", macrons, 1) end
	if b == "4" then final = final:gsub("", grave_accents, 1) end
	if b == "2" or b == "5" then final = final:gsub("", acute_accents, 1) end
	return final
end

function export.jyutping_to_ipa(text)
	if type(text) == "table" then text = text.args end

	if text:find("") then error("Invalid tone in Jyutping.") end
	if text:find("") then error("Please do not capitalize the Jyutping.") end
	if text:find("%-") then error("Please do not hyphenate the Jyutping.") end
	if text:find("") then error("Error in the Jyutping transcription.") end

	text = text:lower()
	text = text:gsub("jy()", "j%1")
	text = text:gsub("%.%.%.", " ")
	text = text:gsub(",", "隔"):gsub("隔 ", ", ")
	local reading = split(text, "隔")
	
	local function retrieve_ipa1(a,b,c,d,e)
		return ipa_initial .. ipa_syllabic .. ipa_tone .. ipa_tone_sandhi .. ipa_tone
	end
	
	local function retrieve_ipa2(a,b,c,d,e,f)
		return (ipa_initial or error(("Unrecognised initial: \"%s\""):format(a))) ..
			(ipa_nucleus or error(("Unrecognised nucleus: \"%s\""):format(b))) ..
			(ipa_coda or error(("Unrecognised coda: \"%s\""):format(c))) ..
			(ipa_tone or error(("Unrecognised tone: \"%s\""):format(d))) ..
			ipa_tone_sandhi ..
			(ipa_tone or error(("Unrecognised tone: \"%s\""):format(f)))
	end
	
	local function get_entering_tone(a,b) return a .. entering_tones end
	
	for i = 1,#reading do
		reading = reading:gsub("()", "%1 "):gsub("", "")
		local syllable = split(reading:lower(), " ")
		for i = 1,#syllable do
			syllable = syllable:gsub("()yu", "%1hyu")
			syllable = syllable:gsub("()oe", "%1hoe")
			syllable = syllable:gsub("()eo", "%1heo")
			if (not syllable:find("^??+?g???$") and not syllable:find("^h?g???$")) and syllable:find("") then
				error("Incorrect Jyutping format. Please check!")
			end
			syllable = syllable:gsub("^(h?)(g?)()(?)(?)$", retrieve_ipa1)
			syllable = syllable:gsub("()()", get_entering_tone)
			syllable = syllable:gsub("()()$", get_entering_tone)
			for regex_idx,regex_pair in ipairs(ipa_preprocess) do
				syllable = ugsub(syllable,regex_pair,regex_pair)
			end
			syllable = ugsub(syllable, "spăn", "span")
			syllable = ugsub(syllable,
				"(??)(?)(?g?)()(?)(?)",
				retrieve_ipa2)
		end
		reading = table.concat(syllable, " ")
	end
	return table.concat(reading, "/, /")
end

function export.jyutping_to_yale(text)
	if type(text) == "table" then text = text.args end

	text = text:gsub("jy()", "j%1")
	text = text:gsub(",", "隔"):gsub("隔 ", ", ")
	local reading = split(text, "隔")
	
	local function yale_tone2(a, b) return yale_tone((yale_final or a), b) end
	
	for i = 1,#reading do
		reading = reading:gsub("%-", "")
		reading = reading:gsub("()", "%1 ")
		local syllables = split(mw.ustring.lower(reading), " ",true)
		for j = 1,#syllables do
			local text = syllables
			
			if text:find("jy") then error("wrong usage of 'jy' in Jyutping") end
			text = text:gsub("",{ = "1",  = "3",  = "6"})
			text = text:gsub("^m$",{ = "{{懸停|或m̀|m̄}}",  = "ḿ",  = "m",  = "m̀h",  = "ḿh",  = "mh"})
			text = text:gsub("^ng$",{ = "{{懸停|或ǹg|n̄g}}",  = "ńg",  = "ng",  = "ǹgh",  = "ńgh",  = "ngh"})
			text = text:gsub("jy?", "y")
			text = text:gsub("",{ = "j",  = "ch"})
			text = text:gsub("(???)()", yale_tone2)
			text = text:gsub("(yu?)()", yale_tone)
			text = ugsub(text, "",{ = "{{懸停|或à|ā}}",  = "{{懸停|或è|ē}}",  = "{{懸停|或ì|ī}}",  = "{{懸停|或ò|ō}}",  = "{{懸停|或ù|ū}}"})
			text = text:gsub("{{懸停|或(+)|(+)}}", '<span style="cursor:help" title="or %1">%2</span>')
			
			syllables = text
		end
		reading = table.concat(syllables, " ")
		if reading:find("沒有耶魯拼音") then
			reading = "colloquial sounds not defined"
		end
	end
	return table.concat(reading, ", ")
end

function export.jyutping_to_cantonese_pinyin(text)
	if type(text) == "table" then text = text.args end
	
	text = text:gsub("jy()", "j%1")
	text = text:gsub(",", "隔"):gsub("隔 ", ", ")
	local reading = split(text, "隔")
	for i=1,#reading do
		for regex, replace in pairs(canton_pinyin_regex) do
			reading = ugsub(reading, regex, replace)
		end
	end
	return table.concat(reading, ", ")
end

function export.jyutping_to_guangdong(text)
	if type(text) == 'table' then text = text.args end
	
	local palatal = { ='j', ='q', ='x' }
	local function palatalize(a,b) return palatal .. b end
	
	local final = { ='b', ='g', ='d' }
	local function get_final(a,b) return final .. b end

	text = text:gsub(",", "隔"):gsub("隔 ", ", ")
	local reading = split(text, "隔")
	for i, item in ipairs(reading) do
		item = item:gsub('yu', 'ü')
		item = item:gsub('eoi', 'êü')
		item = item:gsub('j', 'y')

		item = item:gsub('', 'ê')
		item = item:gsub('e', 'é')

		item = ugsub(item, '()()',  palatalize)

		item = ugsub(item, '()ü', '%1u')

		item = item:gsub('a+', { ='a', ='e' } )

		item = item:gsub('()w', '%1u')
		item = item:gsub('()u', '%1o')

		item = item:gsub('()(%d)', get_final)

		item = item:gsub('%d%-(%d)', '%1')

		if item:find('é') then
			item = 'colloquial sounds not defined'
		end
		reading = item
	end
	return table.concat(reading, ", ")
end

function export.jyutping_format(text)
	if type(text) == "table" then text = text.args end
	
	if text:find("%[%[") then
		return "just a lengthy text to ensure it works"
	end
	
	text = split(text:gsub(",", "隔"):gsub("隔 ", ", "), "隔")
	for i, to_be_processed in ipairs(text) do
		text = to_be_processed:gsub("%-()", "%1")
	end
	
	return text
end

function export.hoisanva_to_ipa(text)
	local hsv_initial = {
		 = "p",  = "pʰ",  = "ᵐb",  = "f",  = "v",
		 = "t",  = "tʰ",  = "ⁿd",  = "l",
		 = "k",  = "kʰ",  = "ᵑɡ", 
		 = "t͡s",  = "t͡sʰ",
		 = "ʒ",  = "s",  = "h",  = ""
	}
	
	local hsv_final = {
		 = "a",  = "ai",  = "au",  = "am",
		 = "an",  = "aŋ",  = "ap̚",  = "at̚",
		 = "ak̚", 

		 = "i",  = "iu",  = "im",  = "in", 
		 = "ip̚",  = "it̚",

		 = "iɛ",  = "iau",  = "iam",  = "iaŋ", 
		 = "iap̚",  = "iak̚",

		 = "u",  = "ui",  = "un",  = "ut̚", 

		 = "ei",  = "eu",  = "em",  = "en", 
		 = "ɵŋ",  = "ep̚",  = "et̚",  = "ɵk̚",  = "ɵt̚",

		 = "ᵘɔ",  = "ᵘɔi",  = "ᵘɔn",  = "ɔŋ", 
		 = "ᵘɔt̚",  = "ɔk̚", 
		
		 = "m̩"
	}
	
	local hsv_tone = { "³³", "⁵⁵", "²²", "²¹", "³²" }
	
	local gsplit = mw.text.gsplit

	local result = {}
	for word in gsplit(text, ",") do
		local initial, final, tone, tone_ch, word_result = "", "", "", "", {}
		for syllable in gsplit(word, " ") do
			initial, final, tone, tone_ch = syllable:match("^(*)(*)()(??%*?)$")
			if final == "" then final, initial = initial, "" end
			
			if not hsv_initial or not hsv_final or not hsv_tone or (tone == "2" and tone_ch == "*") then
				error("Syllable '" .. syllable .. "' is not a valid syllable for IPA conversion.")
			end
			
			table.insert(word_result,
				hsv_initial .. hsv_final .. hsv_tone ..
				(tone_ch ~= "" and "⁻" or "") ..
				(tone_ch == "*" and hsv_tone or (tone_ch:find("^%-") and hsv_tone or "")) ..
				(tone_ch:sub(-1, -1) == "*" and "⁵" or ""))
		end
		table.insert(result, table.concat(word_result, " "))
	end
	return "/" .. table.concat(result, "/, /") .. "/"
end

return export