Module:mns-nor-IPA

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

This module is ready to use.
This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

--This code is borrowed and expanded from ] made by ], used with his explicid permission!

local export = {}

local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("mns-nor")
local rsub = mw.ustring.gsub
local rlower = mw.ustring.lower
local rlast = require("Module:string/replace last").replace_last

local phon = {
	-- consonants, Both w and β should be present in the pronunciation
	="b",	="w",	="ɣ",	="d",
	="ʒ",	="z",	="j",	="k",	="l",	="m",
	="ŋ",	="n",	="p",	="r",	="s",	="t",
	="ч",  ="f",  ="x" , ="ц",  ="ч",
	="ʃ",	="ɕ",
	-- vowels
	 = "a",  = "ʲe",  = "ʲo",  = "ʲi",
	 = "ʲiː",  = "o",  = "u",  = "uː",  = "ə",  = "e",  = "ʲu",  = "ʲa", ="ъ",
	 = "ʲ",
}

local function phonetic(text)
	text = rlower(text)
	-- general phonology
	text = rsub(text, ".", phon)

	-- assimilation (put it outside, not sure if we need it)
--	local i = 0
--	text = rsub(text, "b(ʲ?)$", "p%1")
--	text = rsub(text, "d(ʲ?)$", "t%1")
--	text = rsub(text, "ɣ(ʲ?)$", "k%1")
--	while i <= 5 do
--		text = rsub(text, "b(ʲ?)", "p%1")
--		text = rsub(text, "d(ʲ?)", "t%1")
--		text = rsub(text, "ɡ(ʲ?)", "k%1")
--		text = rsub(text, "z(ʲ?)", "s%1")
--		text = rsub(text, "ʒ(ʲ?)", "ʃ%1")
--		text = rsub(text, "p(ʲ?)", "b%1")
--		text = rsub(text, "t(ʲ?)", "d%1")
--		text = rsub(text, "k(ʲ?)", "ɡ%1")
--		text = rsub(text, "s(ʲ?)", "z%1")
--		text = rsub(text, "ч(ʲ?)", "ӟ%1")
--		text = rsub(text, "ʃ(ʲ?)", "ʒ%1")
--		i = i + 1
--	end
	--special combinations
	text = rsub(text, "əŋ()", "əŋ%1")
	text = rsub(text, "ʲiŋ^", "jəŋ")
	text = rsub(text, "u()", "ɞ̝%1")
	text = rsub(text, "ʲu()", "ʲɞ̝%1")
	text = rsub(text, "uː()", "ɞ̝ː%1")
	text = rsub(text, "ə()", "ɞ̝%1")
	text = rsub(text, "nɣ", "ŋ")
	text = rsub(text, "ə̄ɣ", "i̬ɣː")
	
	--consonant easing
	text = rsub(text, "()pl", "%1pəl")
	text = rsub(text, "w()()", "wə%1%2")
	text = rsub(text, "β()()", "βə%1%2")
	
	--long vowels
	text = rsub(text, "()̄", "%1ː")
	text = rsub(text, "ə̄", "iː")
	
	--long consonants
	text = rsub(text, "ɣɣ", "ɣː")
	text = rsub(text, "jj", "jː")
	text = rsub(text, "kk", "kː")
	text = rsub(text, "ll", "lː")
	text = rsub(text, "mm", "mː")
	text = rsub(text, "nn", "nː")
	text = rsub(text, "ŋŋ", "ŋː")
	text = rsub(text, "pp", "pː")
	text = rsub(text, "rr", "rː")
	text = rsub(text, "ss", "sː")
	text = rsub(text, "tt", "tː")
	text = rsub(text, "ff", "fː")
	text = rsub(text, "xx", "xː")
	text = rsub(text, "ʃʃ", "ʃː")
	text = rsub(text, "ɕɕ", "ɕː")
	
	-- palatalisation
	text = rsub(text, "tʲ", "c")
	text = rsub(text, "sʲ", "ɕ")
	text = rsub(text, "lʲ", "ʎ")
	text = rsub(text, "nʲ", "ɳ")
	text = rsub(text, "^ʲi", "i")
	text = rsub(text, "^ʲ", "j")
	text = rsub(text, "()ʲ", "%1j")
	text = rsub(text, "()ʲ", "%1j")
	text = rsub(text, "ʲ", "")
	
	-- stress (not yet)
--	if mw.ustring.find(text, "́") == nil then
--		text = rlast(text, "()", "ˈ%1", 1)
--	else
--		text = rsub(text, "()́", "ˈ%1")
--	end
--	text = rsub(text, "()ˈ", "ˈ%1")
--	text = rsub(text, "()ːˈ", "%1ˈ%1")
--	text = rsub(text, "^(ː??ː?)ˈ", "ˈ%1")

	-- affricates
	text = rsub(text, "ц", "t͡s")
	text = rsub(text, "ч", "t͡ɕ")
	
	-- labialized
	text = rsub(text, "kw", "kʷ")
	text = rsub(text, "xw", "xʷ")
	
	-- final adjustments
	text = rsub(text, "ъ", "")
	text = rsub(text, "c", "tʲ")
	text = rsub(text, "ʎ", "lʲ")
	text = rsub(text, "ɳ", "nʲ")
	text = rsub(text, "ə()", "ɪ%1")
	text = rsub(text, "^()ə", "%1i")
	text = rsub(text, "^ə()", "i%1")
	text = rsub(text, "ə$", "i")
	text = rsub(text, "ɞ̝m()", "im%1")
	
	text = rsub(text, "g", "ɡ")
	return text
end

function export.IPA(frame)
	local words = {}
	
	for _, word in ipairs(frame:getParent().args) do
		table.insert(words, word)
	end

	if #words == 0 then
		words = {mw.title.getCurrentTitle().text}
	end
	
	local IPA_results = {}
	
	local repl
	
	for _, word in ipairs(words) do
		if mw.ustring.match(word, "в") then
			repl = phonetic(rsub(word, "в", "β"))
			if mw.ustring.match(repl, "kβ") then repl = "" end
			if mw.ustring.match(repl, "xβ") then repl = "" end
			if repl ~= "" then
				table.insert(IPA_results, { pron = "" })
			end
		end
	end
	
	local repl
	
	for _, word in ipairs(words) do
		if mw.ustring.match(word, "х") then
			repl = phonetic(rsub(word, "х", "χ"))
			if repl ~= "" then
				table.insert(IPA_results, { pron = "" })
			end
		end
	end
	
	for _, word in ipairs(words) do
		table.insert(IPA_results, { pron = "" })
	end
	
	return m_IPA.format_IPA_full { lang = lang, items = IPA_results }
end

return export