Module:User:Catonif/szl-IPA

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


local export = {}

local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("szl")

local V = "aãõɛeɔoɨui";

local di = {
	="t_ʂ", ="ꙮ", ="ʂ", ="d_z",
}

local phon = {
	="a",		="ã",		="b",
	="t_s",	="t_ɕ",	="d",	="ɛ",	="e",
	="f",		="ɡ",		="x",
	="i",		="j",		="k",	="l",
	="w",		="m",		="n",	="ɲ",
	="ɔ",		="ɔW",		="o",	="wɔ", -- õ is dealt with later on
	="p",		="r",		="s",	="ɕ",	="t",
	="u",		="v",		="ɨ",
	="z",		="ʐ",		="ʑ",
}

local function phonemic(text)

	local ante = false;
	local unstressed = false;

	if (text:find('^*')) then
		unstressed = true;
		text = text:sub(2);
	elseif (text:find('^%^')) then
		ante = true;
		text = text:sub(2);
	end

	function rsub(s, r) text = mw.ustring.gsub(text, s, r); end

	text = mw.ustring.lower(text);

	rsub('ch', 'x'); rsub('z', di); rsub('dż', 'd_ʐ'); -- handle digraphs
	rsub(".", phon) -- basic orthographical rules
	rsub('au', 'aW');
	rsub("n()", "ŋ%1"); -- (is this really phonemic?)

	-- palatalisation
	-- palatilisation by <-i->
	local C_palat_by_I = 'bdfɡxklwmnprstvzʐʂ'
	rsub("()i()", function (c, v)
		return (({
			 = 'ɲ',
			 = 'ɕ',  = 'ʑ',
		}) or c .. 'I') .. v;
	end);
	-- palatalisation by front vowels
	local C_palat_by_F = 'bdfɡxklwmnprstvzʐʂ';
	local F = 'eéiy';
	rsub('()()', function (c, v)
		return (({
			 = 'ɲ',
			 = 'ɕ',  = 'ɕ',
			 = 'ʑ',  = 'ʑ',
		}) or c .. 'J') .. v;
	end);

	-- voicing and devoicing
	local T = 'ptsʂɕkx';
	local D = 'bdzʐʑɡ';

	rsub('()v', '%1f');
	rsub('()ꙮ', '%1ʂ'); rsub('ꙮ', 'ʐ');

	local function arr_list(x) local r = ''; for i in pairs(x) do r = r..i; end return r; end
	local devoice = {
		 = 'p',  = 't',  = 'k',
		 = 's',  = 'f',  = 'ʃ',
		 = 'ɕ',  = 'ʂ',
	};
	rsub('$', devoice);

	local voice = {}; for i, v in pairs(devoice) do voice = i; end

	local arr_list_devoice = arr_list(devoice);
	local arr_list_voice = arr_list(voice);

	for _ = 0, 5 do
		rsub('()()', function (a, b) return devoice .. b; end)
		rsub('()()', function (a, b) return voice .. b; end)
	end

	rsub("t()", "t_%1"); rsub("d()", "d_%1"); -- affricates

	-- hyphenation 
	rsub('%.', '!');
	for _ = 0, 1 do
		rsub('()(*)()', function (a, b, c)
			local function find(x) return mw.ustring.find(b, x); end
			if ((mw.ustring.len(b) < 2) or find('^(_.)$')) then
				b = '.'..b;
			else
				local i = 2;
				if (find('^(_.)')) then i = 4; end
				if (mw.ustring.sub(b, i, i):find('^$')) then
					b = '.'..b;
				else
					b = mw.ustring.sub(b, 0, i - 1)..'.'..mw.ustring.sub(b, i);
				end
			end
			return a..b..c;
		end);
	end
	rsub('!', '.')

	-- stress
	if (not unstressed) then
		if (ante) then
			rsub('%.(+%.+%.+)$', 'ˈ%1');
		else
			rsub('%.(+%.+)$', 'ˈ%1');
		end
		if (not mw.ustring.find(text, 'ˈ')) then
			text = 'ˈ' .. text;
		end
	end

	-- this should best happen at the end becase <ɔ̃> is two characters long and would
	-- mess up with bracket catching. in practice it would work as well without this
	-- but it looks bodge-y.
	rsub('õ', 'ɔ̃');
	
	rsub('_', '͡'); rsub('I', 'j'); rsub('J', 'ʲ');

	text = mw.ustring.lower(text);

	return text

end

local function multiword(term)
	if (term:find(' ')) then
		local s = '';
		for v in term:gmatch('+') do
			s = s..phonemic(v)..' ';
		end
		return s:sub(0, -2);
	else
		return phonemic(term);
	end
end

-- for testcases
function export.testcase(text)
	return multiword(text);
end

function export.IPA(frame)
	local terms = {}

	local args = frame:getParent().args;

	for _, term in ipairs(args) do
		table.insert(terms, term)
	end

	if #terms == 0 then
		terms = {mw.title.getCurrentTitle().text}
	end

	local IPA_results = {}

	for _, term in ipairs(terms) do
		table.insert(IPA_results, { pron = "/" .. multiword(term) .. "/" })
	end

	return m_IPA.format_IPA_full { lang = lang, items = IPA_results }
end

return export