Module:User:Thadh/sandbox

Hello, you have come here looking for the meaning of the word Module:User:Thadh/sandbox. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Thadh/sandbox, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Thadh/sandbox in singular and plural. Everything you need to know about the word Module:User:Thadh/sandbox you have here. The definition of the word Module:User:Thadh/sandbox will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Thadh/sandbox, 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("inh")
local rsub = mw.ustring.gsub
local rlower = mw.ustring.lower
local rfind = mw.ustring.find

local V = ""
local C = ""

local function phonetic(text)
	local word = text
	
	text = rlower(text)
	text = rsub(text, "̄", "M")
	text = rsub(text, "хь", "ħ")
	-- vowels
	text = rsub(text, "^(~?)()", "%1й%2")
	text = rsub(text, " (~?)()", " %1й%2")
	text = rsub(text, "(~?)()", "%1й%2")
	text = rsub(text, "ий", "i")
	text = rsub(text, "уй", "i")
	text = rsub(text, "ув", "u")
	text = rsub(text, "ь", "æ")
	text = rsub(text, "а", "ɒ")
	text = rsub(text, "M", "a") -- for respellings
	text = rsub(text, "", "ʌ")
	text = rsub(text, "M", "e") -- for respellings
	text = rsub(text, "", "ɛ")
	text = rsub(text, "M", "o") -- for respellings
	text = rsub(text, "", "ɔ")
	text = rsub(text, "и", "ɪ")
	text = rsub(text, "у", "ʊ")
	-- semivowels
	text = rsub(text, "ʌй", "ɛj") -- ʌj has to be respelled as aj
	text = rsub(text, "ɔй", "oj")
	text = rsub(text, "ʌв", "aw")
	text = rsub(text, "ɔв", "ow")
	-- consonants
	text = rsub(text, "къ", "qʼ")
	text = rsub(text, "()ӏ", "%1ʼ")
	text = rsub(text, "хӏ", "h")
	text = rsub(text, "гӏ", "ʁ")
	text = rsub(text, "ъ", "ʔ")
	text = rsub(text, "ӏ", "ʡ")
	text = rsub(text, "кх", "q")
	text = rsub(text, "к", "k")
	text = rsub(text, "ч", "y")
	text = rsub(text, "ц", "c")
	text = rsub(text, "т", "t")
	text = rsub(text, "п", "p")
	text = rsub(text, "г", "ɡ")
	text = rsub(text, "д", "d")
	text = rsub(text, "б", "b")
	text = rsub(text, "х", "χ")
	text = rsub(text, "ш", "ʃ")
	text = rsub(text, "с", "s")
	text = rsub(text, "ф", "f")
	text = rsub(text, "ж", "ʒ")
	text = rsub(text, "з", "z")
	text = rsub(text, "в", "v")
	text = rsub(text, "н", "n")
	text = rsub(text, "м", "m")
	text = rsub(text, "р", "r")
	text = rsub(text, "л", "l")
	text = rsub(text, "kq", "qq")
	text = rsub(text, "й", "j")
	text = rsub(text, "ь", "")
	-- stress
	if rfind(text, "~") == nil then
		text = rsub(text, "^", "ˈ")
		text = rsub(text, " ", " ˈ")
	else
		text = rsub(text, "^~", "Q")
		text = rsub(text, "~", "ˈ")
	end
	text = rsub(text, "^(ˈ?)(" .. V .. ")", "%1ʔ%2")
	text = rsub(text, " (ˈ?)(" .. V .. ")", " %1ʔ%2")	
	text = rsub(text, "(ˈr?" .. C .. "+ʼ?ʲ?)(r?" .. C .. "ʼ?ʲ?)ʌ", "%1ː%2ə")
	text = rsub(text, "(ˈr?" .. C .. "+ʼ?ʲ?)(r?" .. C .. "ʼ?ʲ?" .. V .. ")", "%1ː%2")
	text = rsub(text, "(ˈr?" .. C .. "+ʼ?ʲ?)(r?" .. C .. "ʼ?ʲ?)%2ʌ", "%1ː%2%2ə")
	text = rsub(text, "(ˈr?" .. C .. "+ʼ?ʲ?)(r?" .. C .. "ʼ?ʲ?)%2ʌ", "%1ː%2%2ə")
	text = rsub(text, "(ˈr?" .. C .. "+ʼ?ʲ?)$", "%1ˑ")
	text = rsub(text, "(ˈr?" .. C .. "+ʼ?ʲ?) ", "%1ˑ ")
	text = rsub(text, "(ˈr?" .. C .. "+ʼ?ʲ?)(r?" .. C .. "+ʼ?ʲ?)ʌ", "%1%2ə")
	text = rsub(text, "(ˈr?" .. C .. "+ʼ?ʲ?n?)(r?" .. C .. "ʼ?ʲ?)$", "%1%2%2")
	text = rsub(text, "(ˈr?" .. C .. "+ʼ?ʲ?n?)(r?" .. C .. "ʼ?ʲ?) ", "%1%2%2 ")
	text = rsub(text, "(ˈr?" .. C .. "+ʼ?ʲ?)(r?" .. C .. "+ʼ?ʲ?)", "%1%2")
	
	text = rsub(text, "(r?" .. C .. "ʼ?ʲ?ː?)(r?" .. C .. "+ʼ?ʲ?)ʌ", "%1%2ə")
	text = rsub(text, "(r?" .. C .. "ʼ?ʲ?ː?)(r?" .. C .. "+ʼ?ʲ?)ʌ", "%1%2ə")
	text = rsub(text, "(r?" .. C .. "ʼ?ʲ?ː?)(r?" .. C .. "+ʼ?ʲ?)ʌ", "%1%2ə")
	text = rsub(text, "(ˈr?" .. C .. "ʼ?ʲ?n?)(r?" .. C .. "ʼ?ʲ?)$", "%1%2%2")
	text = rsub(text, "(ˈr?" .. C .. "ʼ?ʲ?n?)(r?" .. C .. "ʼ?ʲ?) ", "%1%2%2 ")
	
	text = rsub(text, "Q(r?" .. C .. "ʼ?ʲ?)ʌ", "%1ə")
	text = rsub(text, "ʌ(r?" .. C .. "+ʼ?ʲ?ˈ)", "ə%1")
	-- schwa
	text = rsub(text, "(" .. V .. "ː?)(r?" .. C .. "+ʼ?ʲ?)ɪ$", "%1%2(ɪ)")
	text = rsub(text, "(" .. V .. "ː?)(r?" .. C .. "+ʼ?ʲ?)ə$", "%1%2(ə)")
	text = rsub(text, "(" .. V .. "ː?)(r?" .. C .. "+ʼ?ʲ?)ɪ ", "%1%2(ɪ) ")
	text = rsub(text, "(" .. V .. "ː?)(r?" .. C .. "+ʼ?ʲ?)ə ", "%1%2(ə) ")
	text = rsub(text, "(+ʼ?%(?)ə", "%1ʊ")
	text = rsub(text, "%?", "")
	text = rsub(text, "əʁ", "ɑʁ")
	text = rsub(text, "ə()", "a%1")
	text = rsub(text, "(%(?)ə", "%1a")
	text = rsub(text, "ə", "ɨ")
	-- phonetics
	text = rsub(text, "c", "ts")
	text = rsub(text, "y", "tʃ")
	text = rsub(text, "jʌ", "jɛ")
	text = rsub(text, "r(" .. C .. "ʼ?ʲ?)r%1", "r%1%1")
	text = rsub(text, "rhh", "rhrh")
	text = rsub(text, "()(" .. C .. "?)$", "%1%2ʲ")
	text = rsub(text, "()(" .. C .. "?) ", "%1%2ʲ ")
	text = rsub(text, "(" .. C .. "?)%(ɪ", "%1%2ʲ(ɪ")
	text = rsub(text, "x()ʲ", "x%1")
	text = rsub(text, "(" .. C .. ")(ʲ)", "%1ʲ%2ʲ")
	text = rsub(text, "ʲʲ", "ʲ")
	text = rsub(text, "()()", "%1ʷ%2")
	text = rsub(text, "(" .. V .. "ː?)r(" .. V .. ")", "%1ɾ%2")
	text = rsub(text, "rr$", "ɾ̥")
	text = rsub(text, "rr ", "ɾ̥ ")
	text = rsub(text, "eː", "iːɛ̯")
	text = rsub(text, "eˑ", "iɛ̯")
	text = rsub(text, "e", "ʲɛ")
	text = rsub(text, "oː", "uːɔ̯")
	text = rsub(text, "oˑ", "uɔ̯")
	text = rsub(text, "o", "ɔ")
	text = rsub(text, "ɒː", "ɔ̯aː")
	text = rsub(text, "ɒˑ", "ɔ̯a")
	text = rsub(text, "ɒ()", "ɔ%1")
	text = rsub(text, "ɒ", "ɔ̯a")
	text = rsub(text, "æː", "ɛ̯æː")
	text = rsub(text, "æˑ", "ɛ̯æ")
	text = rsub(text, "æ", "æ")
	text = rsub(text, "()a", "%1æ")
	text = rsub(text, "a()", "æ%1")
	text = rsub(text, "a(" .. C .. "ʲ)", "æ%1")
	text = rsub(text, "rh", "ɾ̥")
	text = rsub(text, "zz", "dz")
	text = rsub(text, "ʒʒ", "dʒ")
	text = rsub(text, "(ʲ?)ʡ", "%1ˤ")
	text = rsub(text, "ɨ", "ɪ̈")
	text = rsub(text, "ʊr", "ur")
	text = rsub(text, "jɪ̈", "jɪ")
	text = rsub(text, "()ɪ", "%1i")
	text = rsub(text, "ɪ()", "i%1")
	text = rsub(text, "ɪ(" .. C .. "ʲ)", "i%1")
	text = rsub(text, "ˈ$", "")
	text = rsub(text, "^Q", "ˈ")
	text = rsub(text, "(" .. C .. "ʼ?ʲ?)%1", "%1ː")
	text = rsub(text, "n()", "ŋ%1")
	text = rsub(text, "ː()", "%1ː")
	-- final adjustments
	text = rsub(text, "ts", "t͡s")
	text = rsub(text, "dz", "d͡z")
	text = rsub(text, "tʃ", "t͡ʃ")
	text = rsub(text, "dʒ", "d͡ʒ")
	text = rsub(text, ",", "")
	
	-- irregular words (borrowings etc.)
	if word == "банк" then text = rsub(text, "ʲ", "") end
	
	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 = {}
	
	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