Module:sce-pron

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

Pronunciation module for Dongxiang language. See {{sce-pron}}. All tests passed. (refresh)

TextExpectedActual
test_phonemic_IPA:
Passedbaer/pɑˈɚ//pɑˈɚ/
Passedtiigha/tʰɯˈqɑ//tʰɯˈqɑ/
Passedniere/njəˈrə//njəˈrə/
Passedenzhegve/ənt͡ʂəˈʁə//ənt͡ʂəˈʁə/
Passedxiaojierun (xiaojieruŋ)/ɕjɑwt͡ɕjəˈruŋ//ɕjɑwt͡ɕjəˈruŋ/
Passedershi ('ershi)/ˈɚʂi//ˈɚʂi/
Passedruhher ('ruhher)/ˈʐuhɚ//ˈʐuhɚ/

local export = {}

local gsub = mw.ustring.gsub
local gsplit = mw.text.gsplit
local lower = mw.ustring.lower
local match = mw.ustring.match
local str = require("Module:string")
local trim = mw.text.trim

--[[
	Sourced from A grammatical overview of Santa Mongolian by Kenneth Lynn Field (1997),
	东乡语汉语词典 (Dongxiang-Chinese Dictionary) by Ma Guozhong (马国忠) (2001)
]]--
-- List of valid phonemes
local phons = {
	-- list of valid consonant phonemes
	 = {
		 = "p",  = "pʰ",  = "m",  = "f",
		 = "t",  = "tʰ",  = "n",  = "l",  = "r",
		 = "k",  = "kʰ",  = "q",  = "qʰ",
		 = "x",  = "ʁ",  = "h",
		 = "t͡ɕ",  = "t͡ɕʰ",  = "ɕ",
		 = "t͡ʂ",  = "t͡ʂʰ",  = "ʂ",
		 = "t͡s",  = "t͡sʰ",  = "s",
		 = "w",  = "j"
	},
	-- list of valid vowel phomemes
	 = {
		 = "jɑw",  = "wɑj",
		 = "ɑj",  = "əj",  = "ɑw",  = "əw",  = "ɯ",
		 = "jɑ",  = "jə",  = "ju",  = "wəj",  = "wɑ",
		 = "ɑ",  = "o",  = "ə",  = "i",  = "u"
	},
	-- list of phonetic diphthong representations
	 = {
		 = "i̯ɑu̯~ou̯",  = "u̯ɑi̯~u̯ɛi̯",
		 = "ɑi̯~ɛi̯",  = "ə̝i̯",  = "ɑu̯~ou̯",  = "əu̯~ɤu̯",
		 = "i̯ɑ",  = "i̯ɛ",  = "i̯u", "u̯ɑi̯~u̯ɛi̯",  = "u̯(ə̝)i̯",  = "u̯ɑ"
	}
}
-- List of valid graphemes
local graphs = {
	cons_g = "??", -- list of valid consonant graphemes
	vowel_g = "+" -- list of valid vowel graphemes
}

-- Returns the number of syllables in a given string
local function count_syll(text)
	return str.count(text, "ɚ") + str.count(text, "+")
end

-- Handles ambiguous syllable-final n
local function n_final(text)
	local n = match(text, "n+")
	if n and str.count(text, n) > 1 then
		error("ŋ is ambiguous. Please provide the full respelling.")
	elseif text == "ŋ" then
		text = gsub(text, "n", "ŋ")
	end

	return text
end

-- Adjusts the text including respelling the term
local function adjust(text, etyl)
	text = lower(text) -- make text lowercase
	text = " " .. text .. " " -- make all word borders have a space
	text = gsub(text, "'", "ˈ") -- convert apostrophe to a stress mark
	text = gsub(text, "gvi", "gvii") -- i after gv is pronounced as ii
	text = gsub(text, "(hi)", "%1i") -- same after gh, kh and h
	text = gsub(text, "er()", "ɚ%1") -- "er" is a unique syllable in its own right
	if etyl == "zh" or etyl == "ar" then text = gsub(text, "r", "ʐ") end -- r is pronounced as ʐ in words of Chinese and Arabic origin

	return text
end

-- Convert the text to a phonemic IPA transcription
function export.IPA_m(text, etyl)
	text = n_final(text) -- handle syllable-final n
	text = adjust(text, etyl) -- adjust the text by respelling

	text = gsub(text, "* ", function(word)
		if not match(word, "ˈ") and count_syll(word) > 1 then -- add stress mark to the final syllable if no stress mark is present
			word = match(word, "ɚ ") and gsub(word, "(" .. graphs.cons_g .. "ɚ) ", "ˈ%1 ") or gsub(word, "(" .. graphs.cons_g .. graphs.vowel_g .. "*) ", "ˈ%1 ")
		end

		return gsub(word, graphs.cons_g, phons.cons_m):gsub(graphs.vowel_g, phons.vowel_m)
	end)

	return trim(text)
end

-- Convert the text to a phonetic IPA transcription from the phonemic transcription
function export.IPA_t(text, etyl)
	text = adjust(text, etyl) -- adjust the text by respelling
	gsub(graphs.vowel_g, phons.diph_t)

	return trim(text)
end

function export.show(frame)
	local args = frame:getParent().args -- get the arguments
	local etyl = args.etyl -- get the etymology
	local text = mw.title.getCurrentTitle().text -- get current page title
	local results = {} -- store the results

	if args then
		for _, param in ipairs(args) do
			if param ~= "" then
				table.insert(results, {pron = "/" .. export.IPA_m(param, etyl) .. "/"})
			end
		end
	else
		table.insert(results, {pron = "/" .. export.IPA_m(text, etyl) .. "/"})
	end

	return "*" .. require("Module:IPA").format_IPA_full { lang = require("Module:languages").getByCode("sce"), items = results }
end

return export