This module is used for all Ukrainian headword-line templates. It provides a basic functionality common to all of them, but some of the templates have specific additional functionality to show genders or inflected forms.

Accented headword

szerkesztés

All Ukrainian headword-line templates use the first parameter to provide the headword, with accented vowels where present. For example:

{{uk-noun|соба́ка|m-an}}

The parameter supports all the special features that the |head= parameter on {{head}} does. So you can also use this parameter to link to individual words of a multi-word term. These words can be linked with accents still in place; the module will remove them from the page name before creating a link, just like {{l}} does. If you need to specify accents in multiple alternative ways, use |head2=, |head3= and so on.

All Ukrainian words that have more than one syllable are expected to have accents specified. The module will check the parameter for the presence of accents, and categorize the entry in Category:Ukrainian terms needing accents if none are found. Some words like prepositions really have no inherent accent of their own. For such words, give - as the first parameter. This tells the module that you are sure that the word should not have accents, so that it will not check for them. If you don't know where to place the accents, you can leave the parameter empty, or just write the page name without accents.


local m_common = require("Module:uk-common")

local export = {}

local lang = require("Module:languages").getByCode("uk")

local pos_functions = {}

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local args = frame:getParent().args
	PAGENAME = mw.title.getCurrentTitle().text
	
	local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
	
	local data = {lang = lang, pos_category = poscat, categories = {}, heads = {}, translits = {}, genders = {}, inflections = {}}
	
	-- Get the head parameters
	-- First get the 1st parameter. The remainder is named head2=, head3= etc.
	local head = args[1]; if head == "" then head = nil end
	
	local character_categories = {}
	if mw.ustring.match(PAGENAME, "'") then
		--table.insert(character_categories, "Ukrainian terms spelled with '")
	end
	
	local i = 2
	
	while head do
		if m_common.needs_accents(head) then
			--table.insert(data.categories, "Ukrainian terms needing accents")
		end
		
		table.insert(data.heads, head)
		head = args["head" .. i]; if head == "" then head = nil end
		i = i + 1
	end
	
	if #data.heads == 0 then
		--table.insert(data.categories, "Ukrainian terms needing accents")
	end
	
	-- Get transliteration
	local tr = args["tr"]; if tr == "" then tr = nil end
	table.insert(data.translits, tr)
	
	if pos_functions[poscat] then
		pos_functions[poscat](args, data)
	end
	
	return require("Module:headword").full_headword(data) ..
			require("Module:utilities").format_categories(character_categories, lang)
end

pos_functions["tulajdonnevek"] = function(args, data)
	pos_functions["főnevek"](args, data, true)
end

-- Display additional inflection information for a noun
pos_functions["főnevek"] = function(args, data, no_plural)
	-- Iterate over all gn parameters (g2, g3 and so on) until one is empty
	local g = args[2]; if g == "" then g = nil end
	local i = 2
	
	while g do
		table.insert(data.genders, g)
		g = args["g" .. i]; if g == "" then g = nil end
		i = i + 1
	end
	
	if #data.genders == 0 then
		table.insert(data.genders, "?")
	elseif #data.genders > 1 then
		--table.insert(data.categories, "Ukrainian nouns with multiple genders")
	end
	
	-- Get the genitive parameters
	-- First get the 3rd parameter. The remainder is named gen2=, gen3= etc.
	local genitives = {}
	local form = args[3]; if form == "" then form = nil end
	local i = 2
	
	while form do
		table.insert(genitives, form)
		form = args["gen" .. i]; if form == "" then form = nil end
		i = i + 1
	end
	
	-- Get the plural parameters
	-- First get the 4th parameter. The remainder is named pl2=, pl3= etc.
	local plurals = {}
	local form = args[4]; if form == "" then form = nil end
	local i = 2
	
	while form do
		table.insert(plurals, form)
		form = args["pl" .. i]; if form == "" then form = nil end
		i = i + 1
	end
	
	local mode = plurals[1]
	
	-- Get the feminine parameters
	-- First get the f= parameter. The remainder is named f2=, f3= etc.
	local feminines = {}
	local form = args["f"]; if form == "" then form = nil end
	local i = 2
	
	while form do
		table.insert(feminines, form)
		form = args["f" .. i]; if form == "" then form = nil end
		i = i + 1
	end

	-- Get the masculine parameters
	-- First get the m= parameter. The remainder is named m2=, m3= etc.
	local masculines = {}
	local form = args["m"]; if form == "" then form = nil end
	local i = 2
	
	while form do
		table.insert(masculines, form)
		form = args["m" .. i]; if form == "" then form = nil end
		i = i + 1
	end
	
	-- Process the genders
	local singular_genders = {
		["m-?"] = true,
		["m-an"] = true,
		["m-in"] = true,
		
		["f"] = true,
		["f-?"] = true,
		["f-an"] = true,
		["f-in"] = true,
		
		["n"] = true,
		["n-an"] = true,
		["n-in"] = true}
	
	local plural_genders = {
		["m-?-p"] = true,
		["m-an-p"] = true,
		["m-in-p"] = true,

		["f-?-p"] = true,
		["f-an-p"] = true,
		["f-in-p"] = true,
		
		["n-p"] = true,
		["n-an-p"] = true,
		["n-in-p"] = true}
	
	for i, g in ipairs(data.genders) do
		if g == "m" then
			g = "m-?"
		elseif g == "m-p" then
			g = "m-?-p"
		elseif g == "f" and mode ~= "-" and not no_plural then
			g = "f-?"
		elseif g == "f-p" then
			g = "f-?-p"
		end
		
		if not singular_genders[g] and not plural_genders[g] then
			g = "?"
		end
		
		data.genders[i] = g
		
		-- Categorize by gender
		if g:sub(1,1) == "m" then
			table.insert(data.categories, "ukrán hímnemű főnevek")
		elseif g:sub(1,1) == "f" then
			table.insert(data.categories, "ukrán nőnemű főnevek")
		elseif g:sub(1,1) == "n" then
			table.insert(data.categories, "ukrán semlegesnemű főnevek")
		end
		
		-- Categorize by animacy
		if g:sub(3,4) == "an" then
			--table.insert(data.categories, "Ukrainian animate nouns")
		elseif g:sub(3,4) == "in" then
			--table.insert(data.categories, "Ukrainian inanimate nouns")
		end
		
		-- Categorize by number
		if plural_genders[g] then
			--table.insert(data.categories, "Ukrainian pluralia tantum")
		end
	end
	
	-- Add the genitive forms
	if genitives[1] == "-" then
		table.insert(data.inflections, {label = "[[Appendix:Glossary#indeclinable|indeclinable]]"})
		--table.insert(data.categories, "Ukrainian indeclinable nouns")
	else
		genitives.label = "birtokos"
		genitives.request = false
		
		for i, form in ipairs(genitives) do
			if m_common.needs_accents(form) then
				--table.insert(data.categories, "Ukrainian nouns needing accents")
			end
		end
		
		table.insert(data.inflections, genitives)
	end
	
	-- Add the plural forms
	-- If the noun is a plurale tantum, then ignore the 4th parameter altogether
	if no_plural or genitives[1] == "-" then
		-- do nothing
	elseif plural_genders[data.genders[1]] then
		table.insert(data.inflections, {label = "[[Appendix:Glossary#plurale tantum|plurale tantum]]"})
	elseif mode == "-" then
		table.insert(data.inflections, {label = "[[Appendix:Glossary#uncountable|uncountable]]"})
		--table.insert(data.categories, "Ukrainian uncountable nouns")
	else
		plurals.label = "tsz."
		plurals.request = false
		
		for i, form in ipairs(plurals) do
			if m_common.needs_accents(form) then
				--table.insert(data.categories, "Ukrainian nouns needing accents")
			end
		end
		
		table.insert(data.inflections, plurals)
	end
	
	-- Add the feminine forms
	if #feminines > 0 then
		feminines.label = "nőnemű"
		
		for i, form in ipairs(feminines) do
			if m_common.needs_accents(form) then
				--table.insert(data.categories, "Ukrainian nouns needing accents")
			end
		end
		
		table.insert(data.inflections, feminines)
	end
	
	-- Add the masculine forms
	if #masculines > 0 then
		masculines.label = "hímnemű"
		
		for i, form in ipairs(masculines) do
			if m_common.needs_accents(form) then
				--table.insert(data.categories, "Ukrainian nouns needing accents")
			end
		end
		
		table.insert(data.inflections, masculines)
	end
end

-- Display additional inflection information for a verb
pos_functions["igék"] = function(args, data)
	-- Aspect
	local aspect = args[2]; if aspect == "" then aspect = nil end
	
	if aspect == "impf" then
		table.insert(data.genders, "impf")
		--table.insert(data.categories, "Ukrainian imperfective verbs")
	elseif aspect == "pf" then
		table.insert(data.genders, "pf")
		--table.insert(data.categories, "Ukrainian perfective verbs")
	elseif aspect == "both" then
		table.insert(data.genders, "impf")
		table.insert(data.genders, "pf")
		--table.insert(data.categories, "Ukrainian imperfective verbs")
		--table.insert(data.categories, "Ukrainian perfective verbs")
	else
		table.insert(data.genders, "?")
		--table.insert(data.categories, "Ukrainian verbs needing aspect")
	end
	
	-- Get the imperfective parameters
	-- First get the impf= parameter. The remainder is named impf2=, impf3= etc.
	local imperfectives = {}
	local form = args["impf"]; if form == "" then form = nil end
	local i = 2
	
	while form do
		table.insert(imperfectives, form)
		form = args["impf" .. i]; if form == "" then form = nil end
		i = i + 1
	end
	
	-- Get the perfective parameters
	-- First get the pf= parameter. The remainder is named pf2=, pf3= etc.
	local perfectives = {}
	local form = args["pf"]; if form == "" then form = nil end
	local i = 2
	
	while form do
		table.insert(perfectives, form)
		form = args["pf" .. i]; if form == "" then form = nil end
		i = i + 1
	end

	-- Add the imperfective forms
	if #imperfectives > 0 then
		local impf_parts = {label = "imperfective"}
		
		for i, form in ipairs(imperfectives) do
			table.insert(impf_parts, form)
			
			if m_common.needs_accents(form) then
				--table.insert(data.categories, "Ukrainian verbs needing accents")
			end
		end
		
		table.insert(data.inflections, impf_parts)
	end
	
	-- Add the perfective forms
	if #perfectives > 0 then
		local pf_parts = {label = "perfective"}
		
		for i, form in ipairs(perfectives) do
			table.insert(pf_parts, form)
			
			if m_common.needs_accents(form) then
				--table.insert(data.categories, "Ukrainian verbs needing accents")
			end
		end
		
		table.insert(data.inflections, pf_parts)
	end
end

return export