Module:gem-decl-adj

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

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local m_pron = require("Module:gem-pronunc")
local m_links = require("Module:links")
local m_utils = require("Module:utilities")

local lang = require("Module:languages").getByCode("gem-pro")

local i_muts = m_pron.i_mutations

local decl_data = require("Module:gem-decl-adj/data")
--local decl_data_irreg = require("Module:gem-decl-adj/data/irreg")

local endings = {
	 = "a",  = "i",  = "an/in",  = "u",
}

local endings_reverse = {
	 = "az",  = "iz",  = "ô",  = "uz",
}

local function detect_decl(word, stem)
	if stem then
		return decl, {mw.ustring.sub(word, 1, -(mw.ustring.len(endings_reverse) + 1))}
	else
		for ending, decl in pairs(endings) do
			if mw.ustring.find(word, ending .. "$") then
				return decl, {mw.ustring.sub(word, 1, -(mw.ustring.len(ending) + 1))}
			end
		end
	end
end
		
	
local function add_asterisks(forms, data)
	for _, form in ipairs(forms) do
		for i, subform in ipairs(data.forms) do
			data.forms = "*" .. subform
		end
	end
end

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local parent_args = frame:getParent().args
	if mw.title.getCurrentTitle().nsText ~= "Reconstruction" then return end
	
	local stems = nil
	local decl_type = {}
	local word = mw.title.getCurrentTitle().subpageText
	local args = {}

--	if not decl_data_irreg then
		if frame.args.decl then
			decl_type = frame.args.decl
		else
			if parent_args.stem and parent_args then
				decl_type = parent_args.stem
				stems = {parent_args}
			else
				decl_type, stems = detect_decl(word, parent_args.stem)
			end
		end
		
		if not decl_type then
			error("Unknown declension '" .. decl_type .. "'")
		end
		
		args = require("Module:parameters").process(parent_args, decl_data.params, true)
	
		if stems then
			for i, stem in ipairs(stems) do
				args = stem
			end
		end
--	end

	local data = {forms = {}, categories = {}}
	
	data.head = parent_args or nil
	
	-- Generate the forms
	decl_data(args, data)

	-- Make the table
	return make_table(data)
end

local function show_form(form)
	if not form then
		return "—"
	end
	
	local ret = {}
	
	for key, subform in ipairs(form) do
		if mw.ustring.find(subform, "") or mw.ustring.find(subform, "e") then
			subform = i_muts(subform)
		end
		if subform ~= "—" then
			subform = "*" .. subform
		end
		table.insert(ret, subform)
	end
		
	return table.concat(ret, ", ")
end

local function make_caseline(data, prefix)
	local line = {"sg_m", "sg_f", "sg_n", "pl_m", "pl_f", "pl_n"}
	local ret = {}
	for _, lineform in ipairs(line) do
		table.insert(ret, "| " .. show_form(data.forms) .. "\n")
	end
	return table.concat(ret)
end

local function make_inner_table(data, tcode, str_or_wk)
	table.insert(tcode, '! colspan="999" | ' .. (str_or_wk == "s_" and "Strong" or "Weak") .. [=[ declension
|-
! class="outer" |
! class="outer" colspan="3" | singular
| class="separator" rowspan="7" |
! class="outer" colspan="3" | plural
|-
! 
! masculine
! feminine
! neuter
! masculine
! feminine
! neuter
|-
! ]
]=])
	table.insert(tcode, make_caseline(data, str_or_wk .. "nom"))
	table.insert(tcode, '|-\n! ]\n')
	table.insert(tcode, make_caseline(data, str_or_wk .. "acc"))
	table.insert(tcode, '|-\n! ]\n')
	table.insert(tcode, make_caseline(data, str_or_wk .. "gen"))
	table.insert(tcode, '|-\n! ]\n')
	table.insert(tcode, make_caseline(data, str_or_wk .. "dat"))
	table.insert(tcode, '|-\n! ]\n')
	table.insert(tcode, make_caseline(data, str_or_wk .. "ins"))
end


function make_table(data)
	local pagename = mw.title.getCurrentTitle().subpageText
	local wikicode = {}
	
	table.insert(wikicode, mw.getCurrentFrame():expandTemplate{
		title = 'inflection-table-top',
		args = {
			title = "Declension of ''*" .. pagename .. "'' (" .. data.decl_type .. ")",
			palette = 'orange',
			tall = 'yes',
		}
	})

	if not decl_data.weak_only then
		make_inner_table(data, wikicode, "s_")
		if not decl_data.strong_only then
			table.insert(wikicode, '|-\n| class="separator" colspan="999" |\n|-\n')
		end
	end
	if not decl_data.strong_only then
		make_inner_table(data, wikicode, "w_")
	end
	
	table.insert(wikicode, mw.getCurrentFrame():expandTemplate{ title = 'inflection-table-bottom' })

	return table.concat(wikicode) .. m_utils.format_categories(data.categories, lang)
end

return export