Module:mnp-pron

Hello, you have come here looking for the meaning of the word Module:mnp-pron. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:mnp-pron, but we will also tell you about its etymology, its characteristics and you will know how to say Module:mnp-pron in singular and plural. Everything you need to know about the word Module:mnp-pron you have here. The definition of the word Module:mnp-pron will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:mnp-pron, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
This module page is in beta stage.
Its interface has been stabilised, but the module page may still contain errors. Do not deploy widely until the module page has been tested.

Pronunciation module for Northern Min. See {{zh-pron}}.


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

local gsub = m_string_utils.gsub
local gsplit = mw.text.gsplit
local match = m_string_utils.match
local lower = m_string_utils.lower
local toNFC = mw.ustring.toNFC
local toNFD = mw.ustring.toNFD

local initial_ipa = {
	 = "p",	 = "pʰ",	 = "m",
	 = "t",	 = "tʰ",	 = "n",	 = "l",
	 = "t͡s",	  = "t͡sʰ",  = "s",
	 = "k",	 = "kʰ",	 = "ŋ",	 = "x",
	 = "",
}

local final_ipa = {
	 = "i",  = "u",  = "y",
	 = "a",  = "ia",  = "ua",
	 = "ɛ",  = "iɛ",  = "uɛ",  = "yɛ",
	 = "ɔ",  = "iɔ",
	 = "e",  = "œ",  = "o",
	 = "ai",  = "uai",
	 = "au",  = "iau",
	 = "iu",
	 = "iŋ",  = "uiŋ",  = "yiŋ",
	 = "aŋ",  = "iaŋ",  = "uaŋ",
	 = "ɔŋ",  = "ɔŋ",  = "iɔŋ",  = "iɔŋ",  = "uɔŋ",
	 = "eiŋ", --missing /ieiŋ/
	 = "œyŋ",
	 = "aiŋ",  = "uaiŋ",
}

local tone_marks = ""

local tone_from_mark = {
	 = 1, --陰平 (acute)
	 = 3, --陽平 (circumflex)
	 = 2, --上 (caron)
	 = 3, --陰去 (double overline)
	 = 4, --陽去 (macron)
	 = 5, --陰入 (breve)
	 = 6, --陽入 (grave)
}

local tone_value = {
	 = "⁵⁴", --陰平
	 = "²¹", --上
	 = "³³", --陰去
	 = "⁵⁵", --陽去
	 = "²⁴", --陰入
	 = "⁴²", --陽入
}

--[=[
	Given a syllable, return tone value of the syllable's tone and the syllable without the tone mark
]=]
local function get_tone_value(syllable)
	if match(syllable, "̄̄") then -- check for double macron
		local corrected = gsub(syllable, "̄̄", "̿")
		error("Please change " .. syllable .. " to " .. corrected .. ".")
	end
	local tone = match(syllable, tone_marks)
	if tone then
		return tone_value], gsub(syllable, tone, "")
	else
		error("No tone detected.")
	end
end

function export.rom(text)
	return (text
		:gsub("/", " / ")
		:gsub(">(+)", "<sup>→%1</sup>"))
end

function export.ipa(text)
	text = toNFD(lower(text))
	local words_ipa = {}
	for word in gsplit(text, "/") do
		word = gsub(word, " ", "-")
		local syllables_ipa = {}
		for syllable in gsplit(word, "-") do
			syllable = match(syllable, ">(.*)$") or syllable
			local initial, final, tone_value
			tone_value, syllable = get_tone_value(syllable)
			initial, final = match(syllable, "^(??)(+)$")
			initial, final = toNFC(initial), toNFC(final)
			initial, final = initial_ipa, final_ipa
			table.insert(syllables_ipa, initial..final..tone_value)
		end
		table.insert(words_ipa, table.concat(syllables_ipa, " "))
	end
	return "/" .. table.concat(words_ipa, "/, /") .. "/"
end

return export