Modul:vi-pron

Hej, du er kommet her for at finde betydningen af ordet Modul:vi-pron. I DICTIOUS finder du ikke kun alle ordbogens betydninger af ordet Modul:vi-pron, men du lærer også om dets etymologi, dets karakteristika og hvordan man siger Modul:vi-pron i ental og flertal. Alt, hvad du har brug for at vide om ordet Modul:vi-pron, er her. Definitionen af ordet Modul:vi-pron vil hjælpe dig med at være mere præcis og korrekt, når du taler eller skriver dine tekster. Når du kender definitionen afModul:vi-pron og definitionen af andre ord, beriger du dit ordforråd og får flere og bedre sproglige ressourcer.

Dokumentation for dette modul kan oprettes på Modul:vi-pron/dok

local export = {}
local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local match = mw.ustring.match
--àằầèềìòồờùừỳ áắấéếíóốớúứý ảẳẩẻểỉỏổởủửỷ ãẵẫẽễĩõỗỡũữỹ ạặậẹệịọộợụựỵ
local tone_diacritics = {  = 2,  = 3,  = 4,  = 5,  = 6 }

local tone_contour = {
	 = {  = "˧˧",  = "˨˩",  = "˧˦",  = "˧˦",  = "˧˩",  = "˦ˀ˥",  = "˧˨ʔ" },
	 = {  = "˧˧",  = "˦˩",  = "˦˧˥",  = "˨˩˦",  = "˧˨",  = "˧˨",  = "˨˩ʔ" },
	 = {  = "˧˧",  = "˨˩",  = "˦˥",  = "˦˥",  = "˨˩˦",  = "˨˩˦",  = "˨˩˨" },
}

local initial_ipa = {
	 = { "ʔɓ", "ʔɓ", "ʔɓ" },
	 = { "k", "k", "k" },
	 = { "t͡ɕ", "t͡ɕ", "c" },
	 = { "z", "j", "j" },
	 = { "ʔɗ", "ʔɗ", "ʔɗ" },
	 = { "ɣ", "ɣ", "ɣ" },
	 = { "ɣ", "ɣ", "ɣ" },
	 = { "z", "j", "j" },
	 = { "z", "j", "j" },
	 = { "h", "h", "h" },
	 = { "k", "k", "k" },
	 = { "x", "kʰ", "kʰ" },
	 = { "l", "l", "l" },
	 = { "m", "m", "m" },
	 = { "n", "n", "n" },
	 = { "ŋ", "ŋ", "ŋ" },
	 = { "ŋ", "ŋ", "ŋ" },
	 = { "ɲ", "ɲ", "ɲ" },
	 = { "p", "p", "p" }, -- foreign
	 = { "f", "f", "f" },
	 = { "k", "k", "k" },
	 = { "kw", "kw", "w" },
	 = { "z", "ʐ", "ɹ" },
	 = { "ɹ", "ɹ", "ɹ" },
	 = { "s", "ʂ", "ʂ" },
	 = { "t", "t", "t" },
	 = { "tʰ", "tʰ", "tʰ" },
	 = { "t͡ɕ", "ʈ", "ʈ" },
	 = { "v", "v", "v" },
	 = { "s", "s", "s" },
	 = { "z", "z", "z" },
	 = { "ʔ", "ʔ", "ʔ" },
	 = { "", "", "" },
}

local mvi_initial_ipa = {
	 = "β",  = "β",
	 = "ɓ",
	 = "k",  = "c",
	 = "ð",  = "ɗ",
	 = "ɣ",  = "ɣ",  = "ʝ",
	 = "h",
	 = "k",  = "kʰ",
	 = "l",
	 = "m",
	 = "n",  = "ŋ",  = "ŋ",  = "ɲ",
	 = "p",  = "pʰ",
	 = "ɹ",
	 = "ʂ",
	 = "t",  = "tʰ",  = "ʈ",
	 = "w",
	 = "ɕ",
}

local final_ipa = {
	 = { "aː", "aː", "aː" },
	 = { "aːk̚", "aːk̚", "aːk̚" },
	 = { "ajk̟̚", "at̚", "at̚" },
	 = { "aːj", "aːj", "aːj" },
	 = { "aːm", "aːm", "aːm" },
	 = { "aːn", "aːŋ", "aːŋ" },
	 = { "aːn", "aːn", "aːn" },
	 = { "aːŋ", "aːŋ", "aːŋ" },
	 = { "ajŋ̟", "ɛɲ", "an" },
	 = { "aːw", "aːw", "aːw" },
	 = { "awŋ͡m", "", "" },
	 = { "aːp̚", "aːp̚", "aːp̚" },
	 = { "aːt̚", "aːk̚", "aːk̚" },
	 = { "aw", "aw", "a(ː)w" },
	 = { "aj", "aj", "a(ː)j" },
	 = { "ak̚", "ak̚", "ak̚" },
	 = { "am", "am", "am" },
	 = { "an", "aŋ", "aŋ" },
	 = { "aŋ", "aŋ", "aŋ" },
	 = { "ap̚", "ap̚", "ap̚" },
	 = { "at̚", "ak̚", "ak̚" },
	 = { "ə", "ə", "ə" },
	 = { "ək̚", "ək̚", "ək̚" },
	 = { "əm", "əm", "əm" },
	 = { "ən", "əŋ", "əŋ" },
	 = { "əŋ", "əŋ", "əŋ" },
	 = { "əp̚", "əp̚", "əp̚" },
	 = { "ət̚", "ək̚", "ək̚" },
	 = { "əw", "əw", "əw" },
	 = { "əj", "əj", "əj" },
	 = { "ɛ", "ɛ", "ɛ" },
	 = { "ɛk̚", "ɛk̚", "ɛk̚" },
	 = { "ɛm", "ɛm", "ɛm" },
	 = { "ɛn", "ɛŋ", "ɛŋ" },
	 = { "ɛn", "ɛn", "ɛn" },
	 = { "ɛŋ", "ɛŋ", "ɛŋ" },
	 = { "ɛw", "ɛw", "ɛw" },
	 = { "ɛp̚", "ɛp̚", "ɛp̚" },
	 = { "ɛt̚", "ɛt̚", "ɛk̚" },
	 = { "e", "ej", "ej" },
	 = { "ek̚", "ek̚", "ek̚" },
	 = { "əjk̟̚", "et̚", "əːt̚" },
	 = { "em", "em", "em" },
	 = { "en", "en", "əːn" },
	 = { "eŋ", "eŋ", "eŋ" },
	 = { "əjŋ̟", "en", "əːn" },
	 = { "ep̚", "ep̚", "ep̚" },
	 = { "et̚", "et̚", "əːt̚" },
	 = { "ew", "ew", "ew" },
	 = { "i", "ɪj", "ɪj" },
	 = { "iə", "iə", "iə" },
	 = { "ïk̟̚", "ïk̟̚", "ïk̟̚" },
	 = { "ïk̟̚", "ɨt̚", "ɨt̚" },
	 = { "iək̚", "iək̚", "iək̚" },
	 = { "iəm", "iəm", "im" },
	 = { "iən", "iəŋ", "iəŋ" },
	 = { "iəŋ", "iəŋ", "iəŋ" },
	 = { "iəp̚", "iəp̚", "ip̚" },
	 = { "iət̚", "iək̚", "iək̚" },
	 = { "iəw", "iw", "iw" },
	 = { "im", "im", "im" },
	 = { "in", "in", "ɨn" },
	 = { "ïŋ", "ɨn", "ɨn" },
	 = { "ip̚", "ip̚", "ip̚" },
	 = { "it̚", "it̚", "ɨt̚" },
	 = { "iw", "iw", "iw" },
	 = { "ɔ", "ɔ", "ɔ" },
	 = { "waː", "waː", "waː" },
	 = { "waːk̚", "waːk̚", "waːk̚" },
	 = { "wajk̟̚", "wat̚", "wat̚" },
	 = { "waːj", "waːj", "waːj" },
	 = { "waːm", "waːm", "waːm" },
	 = { "waːn", "waːŋ", "waːŋ" },
	 = { "waːŋ", "waːŋ", "waːŋ" },
	 = { "wajŋ̟", "wɛɲ", "wan" },
	 = { "waːw", "waːw", "waːw" },
	 = { "waːp̚", "waːp̚", "waːp̚" },
	 = { "waːt̚", "waːk̚", "waːk̚" },
	 = { "waj", "waj", "waj" },
	 = { "wa", "wa", "wa" },
	 = { "wak̚", "wak̚", "wak̚" },
	 = { "wam", "wam", "wam" },
	 = { "wan", "waŋ", "waŋ" },
	 = { "waŋ", "waŋ", "waŋ" },
	 = { "wat̚", "wak̚", "wak̚" },
	 = { "awk͡p̚", "awk͡p̚", "awk͡p̚" },
	 = { "wɛ", "wɛ", "wɛ" },
	 = { "wɛm", "wɛm", "wɛm" },
	 = { "wɛn", "wɛŋ", "wɛŋ" },
	 = { "wɛw", "wɛw", "wɛw" },
	 = { "wɛt̚", "wɛk̚", "wɛk̚" },
	 = { "ɔj", "ɔj", "ɔj" },
	 = { "ɔm", "ɔm", "ɔm" },
	 = { "ɔn", "ɔŋ", "ɔŋ" },
	 = { "awŋ͡m", "awŋ͡m", "awŋ͡m" },
	 = { "ɔk̚", "ɔk̚", "ɔk̚" },
	 = { "ɔŋ", "ɔŋ͡m", "ɔŋ" },
	 = { "ɔp̚", "ɔp̚", "ɔp̚" },
	 = { "ɔt̚", "ɔk̚", "ɔk̚" },
	 = { "o", "ow", "ow" },
	 = { "əwk͡p̚", "əwk͡p̚", "əwk͡p̚" },
	 = { "oj", "oj", "oj" },
	 = { "om", "om", "om" },
	 = { "on", "oŋ", "oŋ" },
	 = { "on", "on", "on" },
	 = { "əwŋ͡m", "əwŋ͡m", "əwŋ͡m" },
	 = { "ok̚", "ok̚", "ok̚" },
	 = { "oŋ", "oŋ", "oŋ" },
	 = { "op̚", "op̚", "op̚" },
	 = { "ot̚", "ok̚", "ok̚" },
	 = { "əː", "əː", "əː" },
	 = { "əːj", "əːj", "əːj" },
	 = { "əːm", "əːm", "əːm" },
	 = { "əːn", "əːŋ", "əːŋ" },
	 = { "əːŋ", "əːŋ", "əːŋ" },
	 = { "əːp̚", "əːp̚", "əːp̚" },
	 = { "əːt̚", "əːk̚", "əːk̚" },
	 = { "u", "ʊw", "ʊw" },
	 = { "uə", "uə", "uə" },
	 = { "waːk̚", "waːk̚", "waːk̚" },
	 = { "wajk̟̚", "wat̚", "wat̚" },
	 = { "waːj", "waːj", "waːj" },
	 = { "waːn", "waːŋ", "waːŋ" },
	 = { "waːŋ", "waːŋ", "waːŋ" },
	 = { "wajŋ̟", "wɛɲ", "wan" },
	 = { "waːw", "waːw", "waːw" },
	 = { "waːp̚", "waːp̚", "waːp̚" },
	 = { "waːt̚", "waːk̚", "waːk̚" },
	 = { "waw", "waw", "wa(ː)w" },
	 = { "waj", "waj", "waj" },
	 = { "wa", "wa", "wa" },
	 = { "wak̚", "wak̚", "wak̚" },
	 = { "wam", "wam", "wam" },
	 = { "wan", "waŋ", "waŋ" },
	 = { "waŋ", "waŋ", "waŋ" },
	 = { "wap̚", "wap̚", "wap̚" },
	 = { "wat̚", "wak̚", "wak̚" },
	 = { "wə", "wə", "wə" },
	 = { "wək̚", "wək̚", "wək̚" },
	 = { "wən", "wəŋ", "wəŋ" },
	 = { "wəŋ", "wəŋ", "wəŋ" },
	 = { "wət̚", "wək̚", "wək̚" },
	 = { "wəj", "wəj", "wəj" },
	 = { "ʊwk͡p̚", "ʊwk͡p̚", "ʊwk͡p̚" },
	 = { "wɛ", "wɛ", "wɛ" },
	 = { "wɛn", "wɛŋ", "wɛŋ" },
	 = { "wɛw", "wɛw", "wɛw" },
	 = { "wɛp̚", "wɛp̚", "wɛp̚" },
	 = { "wɛt̚", "wɛt̚", "wɛt̚" },
	 = { "we", "wej", "wej" },
	 = { "wəjk̟̚", "wet̚", "wəːt̚" },
	 = { "wen", "wen", "wəːn" },
	 = { "wəjŋ̟", "wen", "wəːn" },
	 = { "wet̚", "wet̚", "wəːt̚" },
	 = { "weu", "weu", "wew" },
	 = { "uj", "uj", "uj" },
	 = { "win", "win", "wɨn" },
	 = { "wit̚", "wit̚", "wit̚" },
	 = { "um", "um", "ʊm" },
	 = { "un", "un", "ʊwŋ͡m" },
	 = { "ʊwŋ͡m", "ʊwŋ͡m", "ʊwŋ͡m" },
	 = { "ujŋ̟", "un", "uwn" },
	 = { "wɔ", "wɔ", "wɔ" }, 
	 = { "uə", "uə", "uə" }, 
	 = { "uək̚", "uək̚", "uək̚" },
	 = { "uəj", "uj", "uj" },
	 = { "uəm", "uəm", "uəm" },
	 = { "uən", "uəŋ", "uəŋ" },
	 = { "uəŋ", "uəŋ", "uəŋ" },
	 = { "uət̚", "uək̚", "uək̚" },
	 = { "wəː", "wəː", "wəː" },
	 = { "wəːj", "wəːj", "wəːj" },
	 = { "wəːn", "wəːŋ", "wəːŋ" },
	 = { "wəːt̚", "wəːk̚", "wəːk̚" },
	 = { "up̚", "up̚", "ʊp̚" },
	 = { "ut̚", "ʊk̚", "ʊk͡p̚" },
	 = { "wi", "wɪj", "wɪj" },
	 = { "wiə", "wiə", "wiə" },
	 = { "wïk̟̚", "wɨk̟̚", "wɨt̚" },
	 = { "win", "win", "wɨn" },
	 = { "wïk̟̚", "wɨk̟̚", "wɨt̚" },
	 = { "wiə", "wiə", "wiə" },
	 = { "wiən", "wiəŋ", "wiəŋ" },
	 = { "wiəŋ̟", "wiən", "wən" },
	 = { "wiət̚", "wiək̚", "wiək̚" },
	 = { "wïŋ̟", "wɨn", "wɨn" },
	 = { "wip̚", "wip̚", "wip̚" },
	 = { "wit̚", "wɨt̚", "wɨt̚" },
	 = { "wiw", "wiw", "wiw" },
	 = { "ɨ", "ɨ", "ɨ" },
	 = { "ɨə", "ɨə", "ɨə" },
	 = { "ɨk̚", "ɨk̚", "ɨk̚" },
	 = { "ɨj", "ɨj", "ɨj" },
	 = { "ɨm", "ɨm", "ɨm" },
	 = { "ɨn", "ɨŋ", "ɨŋ" },
	 = { "ɨŋ", "ɨŋ", "ɨŋ" },
	 = { "ɨək̚", "ɨək̚", "ɨək̚" },
	 = { "ɨəj", "ɨj", "ɨj" },
	 = { "ɨəm", "ɨəm", "ɨəm" },
	 = { "ɨən", "ɨəŋ", "ɨəŋ" },
	 = { "ɨəŋ", "ɨəŋ", "ɨəŋ" },
	 = { "ɨəp̚", "ɨəp̚", "ɨəp̚" },
	 = { "ɨət̚", "ɨək̚", "ɨək̚" },
	 = { "iəw", "ɨəw", "ɨəw" },
	 = { "ɨt̚", "ɨk̚", "ɨk̚" },
	 = { "iw", "ɨw", "ɨw" },
	 = { "i", "ɪj", "ɪj" },
	 = { "iək̚", "iək̚", "iək̚" },
	 = { "iəm", "iəm", "iəm" },
	 = { "iən", "iəŋ", "iəŋ" },
	 = { "iəŋ", "iəŋ", "iəŋ" },
	 = { "iəp̚", "iəp̚", "iəp̚" },
	 = { "iət̚", "iək̚", "iək̚" },
	 = { "iəw", "iw", "iw" },
}

local varieties = { 
	 = { "Hà Nội", 1 },
	 = { "Huế", 2 },
	 = { "Hồ Chí Minh-byen", 3 },
}

local hcmc_opt_w = {
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,  = true,  = true,
	 = true,
}

local variations = {
	 = { { "^ɹ", "z" }, { " ɹ", " z" } },
	 = { { "z", "j" }, { "ʂ", "s" }, { "kʰ", "x" }, { "awŋ͡m", "ɔŋ" } },
	 = { { "ʂ", "s" }, { "v", "j" }, { "kʰ", "x" }, { "z", "j" } },
}

function export.ipa(frame)
	local p, output = {}, {  = {},  = {},  = {} }
	local output_text = {}
	local pronunciations = {  = {},  = {},  = {} }
	local pagename = gsub(gsub(mw.ustring.lower(mw.title.getCurrentTitle().subpageText), "%-", " "), "%,", "")
	local args = frame:getParent().args
	local mvi = frame.args or nil
	if args then
		for index, item in ipairs(args) do
			table.insert(p, (item ~= "") and mw.ustring.lower(gsub(gsub(item, "%-", " "), "%,", "")) or nil)
		end
	else
		table.insert(p, pagename)
	end
	for variety, _ in ipairs(varieties) do
		table.insert(pronunciations, (args ~= "") and args or nil)
	end
	for i, word in ipairs(p) do
		local pronunciations = {  = {},  = {},  = {} }
		for syllable in mw.text.gsplit(word, " ", true) do
			local ipa = {}
			local initial, final, tone = nil, nil, nil, nil
			tone = 1
			syllable = mw.ustring.toNFD(syllable)
			syllable = gsub(syllable, "(́)", mw.ustring.toNFC)
			
			for diac_pattern, tone_num in pairs(tone_diacritics) do
				if match(syllable, diac_pattern) then
					tone = tone_num
					break
				end
			end
			syllable = mw.ustring.toNFC(gsub(syllable, "", ""))
			if syllable == "gi" or syllable == "gin" then
				syllable = gsub(syllable, "gi", "gii")
			end
			initial = match(syllable, "^g+") or match(syllable, "^(g)")
				or match(syllable, "^g") or match(syllable, "^+") or ""
			initial = (match(syllable, "^giê.") and syllable ~= "giên") and "d" or initial
			initial = match(syllable, "qu$") and "qu" or initial
			final = sub(syllable, mw.ustring.len(initial) + 1, -1)
			for loc, location in pairs(varieties) do
				local ipa, seq, detoned = {}, location, ""
				if mvi then
					if mvi_initial_ipa then
						table.insert(ipa, mvi_initial_ipa)
					else
						local initial_cluster = ""
						for cc in mw.ustring.gcodepoint(initial) do
							local ch = mw.ustring.char(cc)
							initial_cluster = initial_cluster .. mvi_initial_ipa
						end
						table.insert(ipa, initial_cluster)
					end
				elseif initial_ipa then
					table.insert(ipa, initial_ipa)
				else
					local initial_cluster = ""
					initial = gsub(initial, "r$", "ŕ")
					for cc in mw.ustring.gcodepoint(initial) do
						local ch = mw.ustring.char(cc)
						initial_cluster = initial_cluster .. initial_ipa
					end
					initial_cluster = gsub(initial_cluster, "(h)", function(digraph)
						return initial_ipa end)
					table.insert(ipa, initial_cluster)
				end
				if final_ipa then
					detoned = gsub(final_ipa, "^(.+)", function(nucleus)
						if initial .. final == "qua" then
							nucleus = final_ipa
						elseif initial .. final == "qui" then
							nucleus = final_ipa
						end
						if loc == "hcmc" then
							if initial == "q" then
								nucleus = gsub(nucleus, "^u", "w")	
							end
							if hcmc_opt_w then
								nucleus = gsub(nucleus, "^w", "⁽ʷ⁾")
							end
						end
						return nucleus end)
					table.insert(ipa, detoned)
				else
					error(("Unrecognised final: \"%s\""):format(final))
				end
				if tone == 3 and match(final, "") then
					tone = "3a"
				end
				table.insert(ipa, tone_contour)
				table.insert(pronunciations, table.concat(ipa, ""))
			end
		end
		for loc, location in pairs(varieties) do
			table.insert(output, table.concat(pronunciations, " "))
		end
	end
	for loc, location in pairs(varieties) do
		if mvi then
			if loc == "hn" then
				location = "Đông Kinh"
			end
			args, args = "-", "-"
		end
		if args ~= "-" then
			if not args then
				args = table.concat(output, "], [")
				local alternative = args
				for _, variation in ipairs(variations) do
					alternative = gsub(alternative, variation, variation)
				end
				if alternative ~= args then args = args .. "] ~ [" .. alternative end
			end
			if loc == "hcmc" then args = gsub(args, "w", "w") args = gsub(args, "ʔw", "(ʔ)w") end
			table.insert(output_text, location, "\n* ('' .. "|" .. location .. "]]'') " .. 
				"]: <span class=\"IPA\">[" ..
					args .. "]</span>")
		else
			table.insert(output_text, location, "")
		end
	end
	if table.concat(p, "") ~= mw.ustring.lower(pagename) then
		table.insert(output_text, #output_text + 1, "\n* ''Phonetic'': " .. gsub(table.concat(p, ", "), "ŕ", "R"))
	end
	return (gsub(table.concat(output_text, ""), "^\n(.)", "%1"))
end

return export