Module:User:Thadh/orv-IPA

Definition from Wiktionary, the free dictionary
Jump to navigation Jump to search

This is a private module sandbox of Thadh, for their own experimentation. Items in this module may be added and removed at Thadh's discretion; do not rely on this module's stability.


local export = { }

local m_IPA = require("Module:IPA")
local m_a = require("Module:accent qualifier")
local lang = require("Module:languages").getByCode("orv")
local s = mw.ustring.gsub
local title = mw.title.getCurrentTitle().text
local C = "[бвгджзклмнпрстфхцчшщѯѱѳ]"
local P = "[бвгдзклмнпрстфхцѯѱѳ]"
local F = "[иѣѧеьѧѵ]"
local c = {
	[1] = { "(" .. P .. ")%f" .. F, "%1ʲ" },
	[2] = { "дж", "d͡ʑ" },
	[3] = { "б", "b" },
	[4] = { "в", "v" },
	[5] = { "г", "ɡ" },
	[6] = { "д", "d" },
	[7] = { "ж", "ʑ" },
	[8] = { "з", "z" },
	[9] = { "к", "k" },
	[10] = { "л","l" },
	[11] = { "м", "m" },
	[12] = { "н","n" },
	[13] = { "п", "p" },
	[14] = { "р", "r" },
	[15] = { "с", "s" },
	[16] = { "т", "t" },
	[17] = { "ф", "f" },
	[18] = { "х", "x" },
	[19] = { "ц", "t͡s" },
	[20] = { "ч", "t͡ɕ" }, 
	[21] = { "ш", "ɕ" },
	[22] = { "щ", "ɕt͡ɕ" },
	[23] = { "ѯ", "ks" },
	[24] = { "ѱ", "ps" },
	[25] = { "ѳ", "f" },
	[26] = { "(" .. C .. "?)а́", "ˈ%1а" },
	[27] = { "(" .. C .. "?)е́́", "ˈ%1е" }, 
	[28] = { "(" .. C .. "?)и́", "ˈ%1и" }, 
	[29] = { "(" .. C .. "?)о́", "ˈ%1о" },
	[30] = { "(" .. C .. "?)у́", "ˈ%1у" }, 
	[31] = { "(" .. C .. "?)ъ́", "ˈ%1ъ" }, 
	[32] = { "(" .. C .. "?)ꙑ́", "ˈ%1ꙑ" }, 
	[33] = { "(" .. C .. "?)ь́", "ˈ%1ь" }, 
	[34] = { "(" .. C .. "?)ѣ́", "ˈ%1ѣ" }, 
	[35] = { "(" .. C .. "?)ю́", "ˈ%1ю" }, 
	[36] = { "(" .. C .. "?)ꙗ́", "ˈ%1ꙗ" }, 
	[37] = { "(" .. C .. "?)ѧ́", "ˈ%1ѧ" },
	[38] = { "(" .. C .. "?)ѫ́", "ˈ%1ѫ" },
	[39] = { "(" .. C .. "?)ѩ́", "ˈ%1ѩ" },
	[40] = { "(" .. C .. "?)ѭ́", "ˈ%1ѭ" },
	[41] = { "(" .. C .. "?)ѵ́", "ˈ%1ѵ" },
	[42] = { "(" .. P .. ")ю", "%1ʲу" },
	[43] = { "(" .. P .. ")ꙗ", "%1ʲа" },
	[44] = { "(" .. P .. ")ѭ", "%1ʲѫ" },
	[42] = { "а", "a" },
	[43] = { "е", "e" },
	[44] = { "о", "o" },
	[45] = { "у", "u" },
	[46] = { "ъ", "ə" },
	[47] = { "ꙑ", "ɨ" },
	[48] = { "ь", "ɪ" },
	[49] = { "ѧ", "ɛ̃" },
	[50] = { "ѫ", "ɔ̃" },
	[51] = { "ѵ", "i" },
	[52] = { "и", "i" },
	[53] = { "ѣ", "ɛ" },
	[54] = { "ю", "ju" },
	[55] = { "ꙗ", "ja" },
	[56] = { "ѭ", "jɔ̃" },
	[57] = { "ѩ", "jɛ̃" },
}

function export.pronunciation_phonemic(word)
	word = mw.ustring.lower(word)
	for a = 1, #c do
		word = s(word, c[a][1], c[a][2])
	end
	return word
end

function export.show(frame)
	local args = frame:getParent().args
	local p, results, results_L = { }, { }, { }
	if not args[1] or (args[1] == "") then
		error("Please put the word as the first positional parameter!")
	else
		for index, item in ipairs(args) do
			table.insert(p, (item ~= "") and item or nil)
		end
	end
	local separate_L = false
	for _, word in ipairs(p) do
		word = export.pronunciation_phonemic(word)
		table.insert(results, {pron = "/" .. word .. "/"})
		table.insert(results_L, {pron = "/" .. s(s(s(s(word, "ɪ", ""), "ə", ""), "ɛ̃", "a"), "ɔ̃", "u") .. "/"})
		if word ~= s(s(s(s(word, "ɪ", ""), "ə", ""), "ɛ̃", "a"), "ɔ̃", "u") then
			separate_L = true
		end
	end
	
--	local H = ""
--	if mw.ustring.match(title, "^[^%-].+[^%-]$") then
--		H = export.syllabify(title)
--		table.insert(H, 1, "orv")
--		H = "\n* " .. require("Module:hyphenation").hyphenate(H)
--	end
	
	if separate_L then
		return "* " .. m_a.show({"Early East Slavic"}) .. " " .. m_IPA.format_IPA_full(lang, results) .. "\n* " 
		.. m_a.show({"Late East Slavic"}) .. " " .. m_IPA.format_IPA_full(lang, results_L) --.. H
	else
		return "* " .. m_IPA.format_IPA_full(lang, results) --.. H
	end
	
end

return export