Module:ang-noun

Hello, you have come here looking for the meaning of the word Module:ang-noun. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:ang-noun, but we will also tell you about its etymology, its characteristics and you will know how to say Module:ang-noun in singular and plural. Everything you need to know about the word Module:ang-noun you have here. The definition of the word Module:ang-noun will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:ang-noun, 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 m_links = require("Module:links")
local strutils = require("Module:string utilities")

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

local export = {}

local cases = { "nom", "acc", "gen", "dat" }
local numbers = { "sg", "pl" }
local slots_to_accel_form = {}
for _, case in ipairs(cases) do
	for _, number in ipairs(numbers) do
		slots_to_accel_form = case .. "|" .. number
	end
end

local slots_to_args = {
	nom_sg = 1,
	nom_pl = 2,
	acc_sg = 3,
	acc_pl = 4,
	gen_sg = 5,
	gen_pl = 6,
	dat_sg = 7,
	dat_pl = 8,
}

function export.make_table(frame)
	local parent_args = frame:getParent().args
	local params = {
		 = {}, -- To be removed.
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {alias_of = "g"},
	}
	for slot, arg in pairs(slots_to_args) do
		params = {list = slot}
	end
	local args = require("Module:parameters").process(parent_args, params)
	
	local table_args = {
		style = args.style == "right" and "float:right; clear:right;" or "",
		width = args.width or "30",
	}
	
	local accel_lemma_sg = args
	local accel_lemma_pl = args
	local accel_lemma =
		accel_lemma_sg and accel_lemma_sg ~= "—" and accel_lemma_sg ~= "-" and accel_lemma_sg:gsub(",.*", "") or
		accel_lemma_pl and accel_lemma_pl ~= "—" and accel_lemma_pl ~= "-" and accel_lemma_pl:gsub(",.*", "") or
		nil
	for slot, accel_form in pairs(slots_to_accel_form) do
		local form_args = args]
		if #form_args == 0 then
			form_args = {"—"}
		end
		local forms = {}
		for _, form_arg in ipairs(form_args) do
			for _, form in ipairs(mw.text.split(form_arg, ", *")) do
				table.insert(forms, form)
			end
		end
		local table_arg = {}
		for _, form in ipairs(forms) do
			table.insert(table_arg, form == "—" and form or m_links.full_link{
				lang = lang, term = form, accel = {
					form = accel_form,
					lemma = accel_lemma,
				}
			})
			table_args = table.concat(table_arg, ", ")
		end
	end
	if args.num == "pl" then
		table_args.nom_sg = "—"
		table_args.acc_sg = "—"
		table_args.gen_sg = "—"
		table_args.dat_sg = "—"
	elseif args.num == "sg" then
		table_args.nom_pl = "—"
		table_args.acc_pl = "—"
		table_args.gen_pl = "—"
		table_args.dat_pl = "—"
	end

	local type = ''
	if args then
		type = type .. (args:gsub("^%l", string.upper))
	end
	if args.g then
		type = type .. " (" .. (
			args.g == "m" and "masculine" or
			args.g == "f" and "feminine" or
			args.g == "n" and "neuter" or
			error("Unrecognized gender '" .. args.g .. "'")
		) .. ")"
	end
	type = type .. ':'

	local table = type .. (type and '\n')
	table = table .. mw.getCurrentFrame():expandTemplate{ 
		title = 'inflection-table-top', 
		args = {
			title = '-',
			palette = 'indigo'
		}
	}
	table = table .. [=[
! 
! singular
! plural
|-
! ]
| {nom_sg}
| {nom_pl}
|-
! ]
| {acc_sg}
| {acc_pl}
|-
! ]
| {gen_sg}
| {gen_pl}
|-
! ]
| {dat_sg}
| {dat_pl}
]=]
	table = table .. mw.getCurrentFrame():expandTemplate{ title = 'inflection-table-bottom' }
	
	return strutils.format(table, table_args)
end

return export

-- For Vim, so we get 4-space tabs
-- vim: set ts=4 sw=4 noet: