Module:orv-IPA

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

local K = mw.ustring.char(0x0311)
local A = mw.ustring.char(0x0301)
local V = ""
local I = ""
local F = ""
local P = ""
local H = ""
local C = ""

local phon = {
	="ɑ",	="b",	="ʋ",	="ɡ",	="d",
	="ɛ",	="ʑ",	="z",	="i",	="k",
	="l",	="m",	="n",	="ɔ",	="p",
	="r",	="s",	="t",	="u",	="f",
	="x",	="ɕ",	="ʊ",	="ɯ",	="ɪ",
	="eː", ="u",	="ɑ",	="ɛ̃", ="õ",
	="ɛ̃",	="õ",	="ks",	="ps",	="f",
	="t͡sʲ", ="t͡ɕ", ="ɕt͡ɕ", ="i",
}

local function format_accent(qual)
	return m_a.format_qualifiers(lang, {qual})
end

local function convert(text, temp)
	-- stress is necessary (1)
	local Diff = mw.ustring.len(text) - mw.ustring.len(rsub(text, V, ""))
	if Diff <= 1 then Diff = 0 end
	
	-- convert
	local T = temp
	text = rlower(text)
	-- long o
	text = rsub(text, "о" .. K, "o" .. A .. "ː")
	-- жд
	text = rsub(text, "жд%f" .. F, "ʑd͡ʑ")
	-- iotation
	text = rsub(text, "^(" .. I .. ")", "j%1")
	text = rsub(text, "(" .. V .. A .. "?)(" .. I .. ")", "%1j%2")
	-- palatals
	text = rsub(text, "(" .. P .. ")" .. K, "%1ʲ")
	if T >= 1 then
		-- palatalisation
		text = rsub(text, "(" .. H .. ")%f" .. F, "%1ʲ")
	end
	-- stress
	if T >= 2 then
		text = rsub(text, "" .. A, "ˈW")
		text = rsub(text, "" .. A, "ˈY")
	end
	text = rsub(text, "(" .. V .. ")" .. A, "ˈ%1")
	local i = 1
	while i <= 6 do
		text = rsub(text, "(" .. C .. "ʲ?)ˈ", "ˈ%1")
		i = i + 1
	end
	if T >= 2 then
		-- yer-loss
		local index = 1
		while index <= 10 do -- random number that should cover it
			text = lsub(text, "", "Q", 1)
			text = rsub(text, "jь", "ji")
			text = rsub(text, "(" .. C .. "?" .. C .. "?" .. C .. "?" .. C .. "?ʲ?)Q", "W%1Q")
			text = rsub(text, "(" .. C .. "?" .. C .. "?" .. C .. "?" .. C .. "?ʲ?)Q", "Y%1Q")
			text = rsub(text, "о(" .. A .. "?)(" .. C .. C .. "?ʲ?Q)", "ɔ%1ː%2")
			text = rsub(text, "е(" .. A .. "?)(" .. C .. C .. "?ʲ?Q)", "ɛ%1ː%2")
			index = index + 1
		end
		text = rsub(text, "W", "ɛ")
		text = rsub(text, "Y", "ɔ")
		text = rsub(text, "Q", "")
		-- cluster resolution
		text = rsub(text, "^()()", "%1ɔ%2")
		text = rsub(text, "^(ʲ)()", "%1ɛ%2")
		text = rsub(text, "^()()$", "%1ɔ%2")
		text = rsub(text, "^(ʲ)()$", "%1ɛ%2")
		text = rsub(text, "^(" .. C .. C .. "?ʲ?" .. C .. "?ʲ?" .. "ʲ?)ˈ", "ˈ%1")
	end
	-- general phonology
	text = rsub(text, ".", phon)
	if T >= 1 then
		-- de-nasalisation
		text = rsub(text, "ɛ̃", "a")
		text = rsub(text, "õ", "u")
		text = rsub(text, "ɑ", "a")
	end
	text = rsub(text, "()", "")
	
	-- stress is necessary (2)
	if Diff ~= 0 and mw.ustring.find(text, "ˈ") == nil then
		error("Please add a stress mark to the first parameter!")
	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 E = {}
	local M = {}
	local L = {}
	
	for _, word in ipairs(words) do
		if mw.ustring.match(word, "и" .. A .. "?" .. I) then
			table.insert(E, { pron = "/" .. convert(rsub(word, "и(" .. A .. "?" .. I .. ")", "ь%1"), 0) .. "/" })
			table.insert(M, { pron = "/" .. convert(rsub(word, "и(" .. A .. "?" .. I .. ")", "ь%1"), 1) .. "/" })
			table.insert(L, { pron = "/" .. convert(rsub(word, "и(" .. A .. "?" .. I .. ")", "ь%1"), 2) .. "/" })
		end
		if mw.ustring.match(word, "ꙑ" .. A .. I) then
			table.insert(E, { pron = "/" .. convert(rsub(word, "ꙑ(" .. A .. I .. ")", "ъ%1"), 0) .. "/" })
			table.insert(M, { pron = "/" .. convert(rsub(word, "ꙑ(" .. A .. I .. ")", "ъ%1"), 1) .. "/" })
			table.insert(L, { pron = "/" .. convert(rsub(word, "ꙑ(" .. A .. I .. ")", "ъ%1"), 2) .. "/" })
		end
		if mw.ustring.match(word, "о" .. K .. C .. C .. "?" .. K .. "?") then
			table.insert(L, { pron = "/" .. convert(rsub(word, "о" .. K .. "(" .. C .. C .. "?" .. K .. "?)", "о" .. A .. "%1"), 2) .. "/" })
		end
		if mw.ustring.match(word, "ѣ" .. A .. "?" .. C .. C .. "?" .. K .. "?") then
			table.insert(L, { pron = "/" .. convert(rsub(word, "ѣ(" .. A .. "?" .. C .. C .. "?" .. K .. "?)", "е%1"), 2) .. "/" })
		end
		table.insert(E, { pron = "/" .. convert(word, 0) .. "/" })
		table.insert(M, { pron = "/" .. convert(word, 1) .. "/" })
		table.insert(L, { pron = "/" .. convert(word, 2) .. "/"})
	end
	
	local hide =
		"*" .. format_accent("ca. 9<sup>th</sup> CE") .. " " .. m_IPA.format_IPA_full { lang = lang, items = E } .. "\n*" ..
		format_accent("ca. 11<sup>th</sup> CE") .. " " .. m_IPA.format_IPA_full { lang = lang, items = M } .. "\n*" ..
		format_accent("ca. 13<sup>th</sup> CE") .. " " .. m_IPA.format_IPA_full { lang = lang, items = L }
		
	local show = 
		"*" .. m_IPA.format_IPA_full { lang = lang, items = E } .. "→"
		.. m_IPA.format_IPA_multiple(lang, M) .. "→"
		.. m_IPA.format_IPA_multiple(lang, L) .. ""
		
	-- return function stolen from Kc kennylau, layout idea stolen from grc-IPA
	return '\n<div class="vsSwitcher" data-toggle-category="pronunciations">'
		.. '<span class="vsToggleElement"></span>'
		.. '<div class="vsShow">\n'
		.. show
		.. '\n</div><div class="vsHide">\n'
		.. hide
		.. '</div></div>\n<span></span>'
end

return export