Module:hy-pronunciation

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

This module implements {{hy-pron}}.

For testcases, see Module:hy-pronunciation/testcases.


local export = {}

local m_str_utils = require("Module:string utilities")
local lang = require("Module:languages").getByCode("hy")
local m_IPA = require("Module:IPA")

local toNFC = mw.ustring.toNFC
local ufind = m_str_utils.find
local ugsub = m_str_utils.gsub
local ulower = m_str_utils.lower

-- single characters that map to IPA sounds
local phonemic_chars_map = {
	-- Eastern Armenian
	east = {
		 = "ɑ",
		 = "b",
		 = "ɡ",
		 = "d",
		 = "e",
		 = "z",
		 = "e",
		 = "ə",
		 = "tʰ",
		 = "ʒ",
		 = "i",
		 = "l",
		 = "χ",
		 = "t͡s",
		 = "k",
		 = "h",
		 = "d͡z",
		 = "ʁ",
		 = "t͡ʃ",
		 = "m",
		 = "j",
		 = "n",
		 = "ʃ",
		 = "o",
		 = "t͡ʃʰ",
		 = "p",
		 = "d͡ʒ",
		 = "r",
		 = "s",
		 = "v",
		 = "t",
		 = "ɾ",
		 = "t͡sʰ",
		 = "v",
		 = "pʰ",
		 = "kʰ",
		 = "ev",
		 = "o",
		 = "f",
		 = " ",
		 = "",
		 = "",
	},
	-- Western Armenian
	west = {
		 = "ɑ",
		 = "p",
		 = "k",
		 = "t",
		 = "e",
		 = "z",
		 = "e",
		 = "ə",
		 = "t",
		 = "ʒ",
		 = "i",
		 = "l",
		 = "χ",
		 = "d͡z",
		 = "ɡ",
		 = "h",
		 = "t͡s",
		 = "ʁ",
		 = "d͡ʒ",
		 = "m",
		 = "j",
		 = "n",
		 = "ʃ",
		 = "o",
		 = "t͡ʃ",
		 = "b",
		 = "t͡ʃ",
		 = "ɾ",
		 = "s",
		 = "v",
		 = "d",
		 = "ɾ",
		 = "t͡s",
		 = "v",
		 = "p",
		 = "k",
		 = "ev",
		 = "o",
		 = "f",
		 = " ",
		 = "",
		 = "",
	},
}

-- character sequences of two that map to IPA sounds
local phonemic_2chars_map = {
	east = {
		{ "ու", "u" },
	},
	west = {
		-- if not in the initial position and if not preceded by 
		{
			"(.?.?)յու", -- can be overridden by using "."
			function(before)
				if not (before == "" or ufind(before, "$") or before == "ու") then
					return before .. "ʏ"
				end
			end,
		},
		{ "ու", "u" },
		{ "էօ", "œ" },
		-- Western Armenian inserts ə in the causative
		{ "ցնել", "t͡sənel" },
	},
}

-- single characters that map to IPA sounds
local phonetic_chars_map = {
	-- Eastern Armenian
	east = {
		 = "ɑ",
		 = "b",
		 = "ɡ",
		 = "d",
		 = "e",
		 = "z",
		 = "e",
		 = "ə",
		 = "tʰ",
		 = "ʒ",
		 = "i",
		 = "l",
		 = "χ",
		 = "t͡s",
		 = "k",
		 = "h",
		 = "d͡z",
		 = "ʁ",
		 = "t͡ʃ",
		 = "m",
		 = "j",
		 = "n",
		 = "ʃ",
		 = "o",
		 = "t͡ʃʰ",
		 = "p",
		 = "d͡ʒ",
		 = "r",
		 = "s",
		 = "v",
		 = "t",
		 = "ɾ",
		 = "t͡sʰ",
		 = "v",
		 = "pʰ",
		 = "kʰ",
		 = "ev",
		 = "o",
		 = "f",
		 = " ",
		 = "",
		 = "",
	},
	-- note that the default pronunciation of ostensible /ɾ/ is 
	-- Western Armenian
	west = {
		 = "ɑ",
		 = "pʰ",
		 = "kʰ",
		 = "tʰ",
		 = "e",
		 = "z",
		 = "e",
		 = "ə",
		 = "tʰ",
		 = "ʒ",
		 = "i",
		 = "l",
		 = "χ",
		 = "d͡z",
		 = "ɡ",
		 = "h",
		 = "t͡sʰ",
		 = "ʁ",
		 = "d͡ʒ",
		 = "m",
		 = "j",
		 = "n",
		 = "ʃ",
		 = "o",
		 = "t͡ʃʰ",
		 = "b",
		 = "t͡ʃʰ",
		 = "ɾ",
		 = "s",
		 = "v",
		 = "d",
		 = "ɾ",
		 = "t͡sʰ",
		 = "v",
		 = "pʰ",
		 = "kʰ",
		 = "ev",
		 = "o",
		 = "f",
		 = " ",
		 = "",
		 = "",
	},
}

-- character sequences of two that map to IPA sounds
local phonetic_2chars_map = {
	east = {
		{ "ու", "u" },
	},
	west = {
		-- if not in the initial position and if not preceded by 
		{
			"(.?.?)յու", -- can be overridden by using "."
			function(before)
				if not (before == "" or ufind(before, "$") or before == "ու") then
					return before .. "ʏ"
				end
			end,
		},
		{ "ու", "u" },
		{ "էօ", "œ" },
		-- պ, տ, կ are not voiced after ս and շ
		{ "սպ", "sp" },
		{ "ստ", "st" },
		{ "սկ", "sk" },
		{ "շպ", "ʃp" },
		{ "շտ", "ʃt" },
		{ "շկ", "ʃk" },
		-- Western Armenian inserts ə in the causative
		{ "ցնել", "t͡sʰənel" },
	},
}

function export.phonemic_IPA(phonemic, system)
	if not (phonemic_chars_map and phonemic_2chars_map) then
		error("Invalid system " .. tostring(system))
	end

	phonemic = ulower(phonemic)

	-- then long consonants that are orthographically geminated.

	for _, replacement in ipairs(phonemic_2chars_map) do
		phonemic = ugsub(phonemic, unpack(replacement))
	end

	-- ոու is pronounced ou
	phonemic = ugsub(phonemic, "ոːւ", "օու")

	-- ե and ո are pronounced as je and vo word-initially.
	phonemic = ugsub(phonemic, "^ե", "յէ")
	phonemic = ugsub(phonemic, "^ո", "վօ")
	-- except when followed by another վ.
	phonemic = ugsub(phonemic, "^վօվ", "օվ")

	--final ք, from the ancient plural, is extrasyllabic and should be marked.
	phonemic = ugsub(phonemic, "()ք$", "%1.ք")

	-- ոու is pronounced oov
	phonemic = ugsub(phonemic, "ոու", "օու")

	-- palatalization in the Eastern Armenian sequence -ությ-, especially in the suffix -ություն 
	if system == "east" then
		phonemic = ugsub(phonemic, "ությ", "ուցյ")

		phonemic = ugsub(phonemic, "()()", "%1%2")
	end

	phonemic = ugsub(phonemic, ".", phonemic_chars_map)

	--oov is actually ou
	phonemic = ugsub(phonemic, "oov", "ou")

	if system == "west" then
		phonemic = ugsub(phonemic, "b()", "p%1")
		phonemic = ugsub(phonemic, "d()", "t%1")
		phonemic = ugsub(phonemic, "ɡ()", "k%1")
		phonemic = ugsub(phonemic, "d͡z()", "t͡s%1")
		phonemic = ugsub(phonemic, "d͡ʒ()", "t͡ʃ%1")
		phonemic = ugsub(phonemic, "z()", "s%1")
		phonemic = ugsub(phonemic, "ʒ()", "ʃ%1")
	end

	phonemic = ugsub(phonemic, "ʁ()", "χ%1")
	phonemic = ugsub(phonemic, "v()", "f%1")

	-- generating the stress
	phonemic = ugsub(phonemic, "%S+", function(word)
		-- Do not add a stress mark for monosyllabic words. Check to see if the word contains only a single instance of +.
		local numberOfVowels = select(2, ugsub(word, "", "%0"))

		-- If polysyllabic, add IPA stress mark using the following rules. The stress is always on the last syllable not
		-- formed by schwa . In some rare cases the stress is not on the last syllable. In such cases the stressed vowel
		-- is marked by the Armenian stress character <՛>, e.g. մի՛թե. So:
		--      1) Find the vowel followed by <՛>․ If none, jump to step 2. Else check if it is the first vowel of the word.
		--         If true, put the IPA stress at the beginning, else do step 3.
		--      2) Find the last non-schwa vowel, i.e. ,
		--      3) If the IPA symbol preceding it is , i.e. a vowel, put the stress symbol between them,
		--         if it is NOT , i.e. it is a consonant,
		--         put the stress before that consonant.
		if numberOfVowels > 1 then
			local rcount
			word, rcount = ugsub(word, "(*)՛", "ˈ%1")
			if rcount == 0 then
				word = ugsub(word, "(**)$", "ˈ%1")
				word = ugsub(
					word,
					"(*?*ə*)$",
					"ˈ%1"
				)
			end
			-- Including () in the second and third sets will only work
			-- if () never encloses a vowel.
			word = ugsub(word, "()ˈ(+)()", "%1%2ˈ%3")
			word = ugsub(word, "(.)͡ˈ", "ˈ%1͡")
			return word
		end
	end)

	-- move stress marker out of opening/closing parentheses
	if system == "east" or system == "west" then
		phonemic = ugsub(phonemic, "ˈ%)", ")ˈ")
		phonemic = ugsub(phonemic, "%(ˈ", "ˈ(")
	end

	-- "." prevents assimilation and can act as a dummy initial consonant, so must be removed.
	phonemic = phonemic:gsub("%.", "")

	return toNFC(phonemic)
end

function export.phonetic_IPA(phonetic, system)
	if not (phonetic_chars_map and phonetic_2chars_map) then
		error("Invalid system " .. tostring(system))
	end

	phonetic = ulower(phonetic)

	-- then long consonants that are orthographically geminated.
	phonetic = ugsub(phonetic, "(.)%1", "%1ː")

	for _, replacement in ipairs(phonetic_2chars_map) do
		phonetic = ugsub(phonetic, unpack(replacement))
	end

	-- ոու is pronounced ou
	phonetic = ugsub(phonetic, "ոːւ", "օու")

	-- ե and ո are pronounced as je and vo word-initially.
	phonetic = ugsub(phonetic, "^ե", "յէ")
	phonetic = ugsub(phonetic, "^ո", "վօ")
	-- except when followed by another վ.
	phonetic = ugsub(phonetic, "^վօվ", "օվ")

	-- ոու is pronounced oov
	phonetic = ugsub(phonetic, "ոու", "օու")

	phonetic = ugsub(phonetic, ".", phonetic_chars_map)

	--oov is actually ou
	phonetic = ugsub(phonetic, "oov", "ou")

	-- insertion of the optional glide
	phonetic = ugsub(phonetic, "iɑ", "i(j)ɑ")
	phonetic = ugsub(phonetic, "ie", "i(j)e")
	phonetic = ugsub(phonetic, "io", "i(j)o")
	phonetic = ugsub(phonetic, "iu", "i(j)u")
	phonetic = ugsub(phonetic, "ɑi", "ɑ(j)i")
	phonetic = ugsub(phonetic, "ei", "e(j)i")
	phonetic = ugsub(phonetic, "oi", "o(j)i")
	phonetic = ugsub(phonetic, "ui", "u(j)i")

	-- assimilation: ppʰ = pʰː; ttʰ = tʰː; ; kkʰ = kʰː
	phonetic = ugsub(phonetic, "ppʰ", "pʰː")
	phonetic = ugsub(phonetic, "ttʰ", "tʰː")
	phonetic = ugsub(phonetic, "kkʰ ", "kʰː")

	-- nasal assimilation
	phonetic = ugsub(phonetic, "n(+)", "ŋ%1")

	-- pseudo-palatalization under the influence of Russian 
	--phonetic = ugsub(phonetic, "tj", "t͡sj")
	--phonetic = ugsub(phonetic, "tʰj", "t͡sʰj")
	--phonetic = ugsub(phonetic, "dj", "d͡zj")

	-- palatalization in the Eastern Armenian sequence -ությ-, especially in the suffix -ություն 
	if system == "east" then
		phonetic = ugsub(phonetic, "utʰj", "ut͡sʰj")
	end

	-- trilling of ɾ in some positions 
	--phonetic = ugsub(phonetic, "ɾt", "rt")

	-- devoicing of consonants in some positions
	phonetic = ugsub(phonetic, "bpʰ", "pʰː")
	phonetic = ugsub(phonetic, "dpʰ", "tʰpʰ")
	phonetic = ugsub(phonetic, "ɡpʰ", "kʰpʰ")
	phonetic = ugsub(phonetic, "d͡zpʰ", "t͡sʰpʰ")
	phonetic = ugsub(phonetic, "d͡ʒpʰ", "t͡ʃʰpʰ")
	phonetic = ugsub(phonetic, "vpʰ", "fpʰ")
	phonetic = ugsub(phonetic, "ʒpʰ", "ʃpʰ")

	phonetic = ugsub(phonetic, "btʰ", "pʰtʰ")
	phonetic = ugsub(phonetic, "dtʰ", "tʰː")
	phonetic = ugsub(phonetic, "ɡtʰ", "kʰtʰ")
	phonetic = ugsub(phonetic, "d͡ztʰ", "t͡sʰtʰ")
	phonetic = ugsub(phonetic, "d͡ʒtʰ", "t͡ʃʰtʰ")
	phonetic = ugsub(phonetic, "vtʰ", "ftʰ")
	phonetic = ugsub(phonetic, "ʒtʰ", "ʃtʰ")

	phonetic = ugsub(phonetic, "bkʰ", "pʰkʰ")
	phonetic = ugsub(phonetic, "dkʰ", "tkʰ")
	phonetic = ugsub(phonetic, "ɡkʰ", "kʰː")
	phonetic = ugsub(phonetic, "d͡zkʰ", "t͡sʰkʰ")
	phonetic = ugsub(phonetic, "d͡ʒkʰ", "t͡ʃʰkʰ")
	phonetic = ugsub(phonetic, "vkʰ", "fkʰ")
	phonetic = ugsub(phonetic, "ʒkʰ", "ʃkʰ")

	phonetic = ugsub(phonetic, "bt͡ʃʰ", "pʰt͡ʃʰ")
	phonetic = ugsub(phonetic, "dt͡ʃʰ", "tʰt͡ʃʰ")
	phonetic = ugsub(phonetic, "ɡt͡ʃʰ", "kʰt͡ʃʰ")
	phonetic = ugsub(phonetic, "d͡zt͡ʃʰ", "t͡sʰt͡ʃʰ")
	phonetic = ugsub(phonetic, "d͡ʒt͡ʃʰ", "t͡ʃʰː")
	phonetic = ugsub(phonetic, "vt͡ʃʰ", "ft͡ʃʰ")
	phonetic = ugsub(phonetic, "ʒt͡ʃʰ", "ʃt͡ʃʰ")

	phonetic = ugsub(phonetic, "bt͡sʰ", "pʰt͡sʰ")
	phonetic = ugsub(phonetic, "dt͡sʰ", "tʰt͡sʰ")
	phonetic = ugsub(phonetic, "ɡt͡sʰ", "kʰt͡sʰ")
	phonetic = ugsub(phonetic, "d͡zt͡sʰ", "t͡sʰː")
	phonetic = ugsub(phonetic, "d͡ʒt͡sʰ", "t͡ʃʰt͡sʰ")
	phonetic = ugsub(phonetic, "vt͡sʰ", "ft͡sʰ")
	phonetic = ugsub(phonetic, "ʒt͡sʰ", "ʃt͡sʰ")

	phonetic = ugsub(phonetic, "zpʰ", "spʰ")
	phonetic = ugsub(phonetic, "ztʰ", "stʰ")
	phonetic = ugsub(phonetic, "zkʰ", "skʰ")

	phonetic = ugsub(phonetic, "ʁt͡s", "χt͡s")
	phonetic = ugsub(phonetic, "ʁt͡ʃ", "χt͡ʃ")
	phonetic = ugsub(phonetic, "ʁp", "χp")
	phonetic = ugsub(phonetic, "ʁt", "χt")
	phonetic = ugsub(phonetic, "ʁk", "χk")
	phonetic = ugsub(phonetic, "ʁs", "χs")
	phonetic = ugsub(phonetic, "ʁʃ", "χʃ")

	phonetic = ugsub(phonetic, "vt͡s", "ft͡s")
	phonetic = ugsub(phonetic, "vt͡ʃ", "ft͡ʃ")
	phonetic = ugsub(phonetic, "vp", "fp")
	phonetic = ugsub(phonetic, "vt", "ft")
	phonetic = ugsub(phonetic, "vk", "fk")
	phonetic = ugsub(phonetic, "vs", "fs")
	phonetic = ugsub(phonetic, "vʃ", "fʃ")

	if system == "west" then
		phonetic = ugsub(phonetic, "χd͡z", "χt͡s")
		phonetic = ugsub(phonetic, "χd͡ʒ", "χt͡ʃ")
		phonetic = ugsub(phonetic, "χb", "χp")
		phonetic = ugsub(phonetic, "χd", "χt")
		phonetic = ugsub(phonetic, "χɡ", "χk")
	end

	if system == "west" then
		phonetic = ugsub(phonetic, "t͡ʃʰd͡z", "t͡ʃʰt͡s")
		phonetic = ugsub(phonetic, "t͡sʰd͡z", "t͡sʰt͡s")
		phonetic = ugsub(phonetic, "pʰd͡z", "pʰt͡s")
		phonetic = ugsub(phonetic, "tʰd͡z", "tʰt͡s")
		phonetic = ugsub(phonetic, "kʰd͡z", "kʰt͡s")

		phonetic = ugsub(phonetic, "t͡ʃʰd͡ʒ", "t͡ʃʰt͡ʃ")
		phonetic = ugsub(phonetic, "t͡sʰd͡ʒ", "t͡sʰt͡ʃ")
		phonetic = ugsub(phonetic, "pʰd͡ʒ", "pʰt͡ʃ")
		phonetic = ugsub(phonetic, "tʰd͡ʒ", "tʰt͡ʃ")
		phonetic = ugsub(phonetic, "kʰd͡ʒ", "kʰt͡ʃ")

		phonetic = ugsub(phonetic, "t͡ʃʰb", "t͡ʃʰp")
		phonetic = ugsub(phonetic, "t͡sʰb", "t͡sʰp")
		phonetic = ugsub(phonetic, "pʰb", "pʰp")
		phonetic = ugsub(phonetic, "tʰb", "tʰp")
		phonetic = ugsub(phonetic, "kʰb", "kʰp")

		phonetic = ugsub(phonetic, "t͡ʃʰd", "t͡ʃʰt")
		phonetic = ugsub(phonetic, "t͡sʰd", "t͡sʰt")
		phonetic = ugsub(phonetic, "pʰd", "pʰt")
		phonetic = ugsub(phonetic, "tʰd", "tʰt")
		phonetic = ugsub(phonetic, "kʰd", "kʰt")

		phonetic = ugsub(phonetic, "t͡ʃʰɡ", "t͡ʃʰk")
		phonetic = ugsub(phonetic, "t͡sʰɡ", "t͡sʰk")
		phonetic = ugsub(phonetic, "pʰɡ", "pʰk")
		phonetic = ugsub(phonetic, "tʰɡ", "tʰk")
		phonetic = ugsub(phonetic, "kʰɡ", "kʰk")
	end

	-- prothetic ə before {s/ʃ/z}{p/t/k/b/d/g} in Western Armenian; this rule is not the norm in Eastern Armenian anymore
	if system == "west" then
		phonetic = ugsub(phonetic, "^(+)", "ə%1")
	end

	-- generating the stress
	phonetic = ugsub(phonetic, "%S+", function(word)
		-- Do not add a stress mark for monosyllabic words. Check to see if the word contains only a single instance of +.
		local numberOfVowels = select(2, ugsub(word, "", "%0"))

		-- If polysyllabic, add an acute using the following rules. The stress is always on the last syllable not
		-- formed by schwa . In some rare cases the stress is not on the last syllable. In such cases the stressed vowel
		-- is marked by the Armenian stress character <՛>, e.g. մի՛թե. So:
		--      1) Find the vowel followed by <՛> and put the acute on it․ If none, go to step 2.
		--      2) Find the last non-schwa vowel, i.e. , and put the acute on it.
		if numberOfVowels > 1 then
			local rcount
			word, rcount = ugsub(word, "()՛", "%1́")
			if rcount == 0 then
				word = ugsub(word, "()(*)(ə??)$", "%1́%2%3")
			end
			return word
		end
	end)

	-- change phonetically-impossible ɾː to ɹː
	if system == "east" or system == "west" then
		phonetic = ugsub(phonetic, "ɾː", "ɹː")
	end

	if system == "east" or system == "west" then
		phonetic = ugsub(phonetic, "()%1͡()(ʰ?)", "%1̚%1͡%2%3")
		phonetic = ugsub(phonetic, "()͡()(ʰ?)ː", "%1̚%1͡%2%3")
	end
	
	-- "." prevents assimilation and can act as a dummy initial consonant, so must be removed.
	phonetic = phonetic:gsub("%.", "")

	return toNFC(phonetic)
end

function export.generic_IPA(frame) 
	local params = {
		 = {},
		 = {},
	}
	
	local parent_args = frame:getParent().args
	local args = require("Module:parameters").process(parent_args, params, nil, "hy-pronunciation", "IPA")
	
	local pagename = mw.loadData("Module:headword/data").pagename

	return m_IPA.format_IPA_full({
			lang = lang,
			items = {
					{ pron = "/" .. export.phonemic_IPA(args or pagename, args.system or "east") .. "/" },
					{ pron = " or pagename, args.system or "east") .. "]" },
				},
		})
end

function export.IPA(frame)

	local params = {
		 = { type = "boolean", default = "true" },
		 = { type = "boolean", default = "true" },
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
	}

	local parent_args = frame:getParent().args
	local args = require("Module:parameters").process(parent_args, params, nil, "hy-pronunciation", "IPA")
	local lines = {}
	local function ins(text)
		table.insert(lines, text)
	end
	local function get_pagename()
		return args.pagename or mw.loadData("Module:headword/data").pagename
	end

	local function insert_east_or_west(prons, system, standard_accent, coll_pron, coll_qualifier)
		local items = {}
		for _, pron in ipairs(prons) do
			if pron then
				table.insert(items, { pron = "/" .. export.phonemic_IPA(pron, system) .. "/" })
				table.insert(items, { pron = "" })
			end
		end
		ins("* " .. m_IPA.format_IPA_full({
			lang = lang,
			items = items,
			a = { standard_accent },
		}))
		if coll_pron then
			ins("** " .. m_IPA.format_IPA_full({
				lang = lang,
				items = {
					{ pron = "/" .. export.phonemic_IPA(coll_pron, system) .. "/" },
					{ pron = "" },
				},
				q = { coll_qualifier, "colloquial" },
			}))
		end
	end
	if args.E then
		insert_east_or_west(
			{ args.e or args or get_pagename(), args, args.e2 },
			"east",
			"hy-E",
			args.coll,
			"Eastern Armenian"
		)
	end
	if args.W then
		insert_east_or_west(
			{ args.w or args or get_pagename(), args, args.w2 },
			"west",
			"hy-W",
			args.collw,
			"Western Armenian"
		)
	end

	return table.concat(lines, "\n")
end

return export