Module:jugs-noun-cell: Difference between revisions

From Linguifex
Jump to navigation Jump to search
Wfeozawra (talk | contribs)
No edit summary
Wfeozawra (talk | contribs)
No edit summary
Tag: Reverted
Line 41: Line 41:
}
}
function export.create(frame)
function export.show(frame)
local args = frame:getParent().args
local args = frame.args
local links = {}
local root = args[1] or error("No root provided.")
if not args[1] or args[1] == "" then
local decltype = args["type"] or error("No declension type provided.")
return "―"
 
else
local decl = decls[decltype]
local accel_form = args[2]
if not decl then
local accel
error("Unknown declension type: " .. decltype)
if accel_form then
local mode = args[3]
if mode and mode_prefix[mode] then
accel_form = mode_prefix[mode] .. accel_form
end
if accel_forms[accel_form] then
if mode and mode_prepend[mode] then
accel_form = mode_prepend[mode] .. accel_forms[accel_form]
else
accel_form = accel_forms[accel_form]
end
end
accel = {form = accel_form}
end
local words = mw.text.split(args[1], "%s*,%s*")
end
end
local data = { forms = {} }
decl({ root }, data)
local function showForm(case, number)
local key = cases[case].short_form .. "-" .. number
return data.forms[key] or "—"
end
local function small(text)
return frame:preprocess("{{small|" .. text .. "}}")
end
local out = {}
table.insert(out, '{| class="wikitable" style="text-align:center;"')
table.insert(out, '|-')
table.insert(out, '! Number !! Case !! Declension')
-- Singular rows
table.insert(out, '|-')
table.insert(out, '! rowspan=4 | Singular')
table.insert(out, '! ' .. small("nom."))
table.insert(out, '| ' .. showForm("nominative", "sg"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("acc."))
table.insert(out, '| ' .. showForm("accusative", "sg"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("dat."))
table.insert(out, '| ' .. showForm("dative", "sg"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("gen."))
table.insert(out, '| ' .. showForm("genitive", "sg"))
-- Plural rows
table.insert(out, '|-')
table.insert(out, '! rowspan=4 | Plural')
table.insert(out, '! ' .. small("nom."))
table.insert(out, '| ' .. showForm("nominative", "pl"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("acc."))
table.insert(out, '| ' .. showForm("accusative", "pl"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("dat."))
table.insert(out, '| ' .. showForm("dative", "pl"))
table.insert(out, '|-')
table.insert(out, '! ' .. small("gen."))
table.insert(out, '| ' .. showForm("genitive", "pl"))
table.insert(out, '|}')
return table.concat(out, '\n')
return table.concat(out, '\n')
end
end


return export
return export

Revision as of 02:19, 18 March 2026

Documentation for this module may be created at Module:jugs-noun-cell/doc

local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("non")
local export = {}

local accel_forms = {
	--NOUNS
	nsi = "nom|s",
	nsd = "def|nom|s",
	npi = "nom|p",
	npd = "def|nom|p",
	asi = "acc|s",
	asd = "def|acc|s",
	api = "acc|p",
	apd = "def|acc|p",
	dsi = "dat|s",
	dsd = "def|dat|s",
	dpi = "dat|p",
	dpd = "def|dat|p",
	gsi = "gen|s",
	gsd = "def|gen|s",
	gpi = "gen|p",
	gpd = "def|gen|p",
	
	--LAUDATIVES
	nsi_la = "nom|s|la",
	nsd_la = "def|nom|s|la",
	npi_la = "nom|p|la",
	npd_la = "def|nom|p|la",
	asi_la = "acc|s|la",
	as_lad = "def|acc|s|la",
	api_la = "acc|p|la",
	apd_la = "def|acc|p|la",
	dsi_la = "dat|s|la",
	dsd_la = "def|dat|s|la",
	dpi_la = "dat|p|la",
	dpd_la = "def|dat|p|la",
	gsi_la = "gen|s|la",
	gsd_la = "def|gen|s|la",
	gpi_la = "gen|p|la",
	gpd_la = "def|gen|p|la",
	
}
function export.show(frame)
	local args = frame.args
	local root = args[1] or error("No root provided.")
	local decltype = args["type"] or error("No declension type provided.")

	local decl = decls[decltype]
	if not decl then
		error("Unknown declension type: " .. decltype)
	end

	local data = { forms = {} }
	decl({ root }, data)

	local function showForm(case, number)
		local key = cases[case].short_form .. "-" .. number
		return data.forms[key] or "—"
	end

	local function small(text)
		return frame:preprocess("{{small|" .. text .. "}}")
	end

	local out = {}
	table.insert(out, '{| class="wikitable" style="text-align:center;"')
	table.insert(out, '|-')
	table.insert(out, '! Number !! Case !! Declension')

	-- Singular rows
	table.insert(out, '|-')
	table.insert(out, '! rowspan=4 | Singular')
	table.insert(out, '! ' .. small("nom."))
	table.insert(out, '| ' .. showForm("nominative", "sg"))

	table.insert(out, '|-')
	table.insert(out, '! ' .. small("acc."))
	table.insert(out, '| ' .. showForm("accusative", "sg"))

	table.insert(out, '|-')
	table.insert(out, '! ' .. small("dat."))
	table.insert(out, '| ' .. showForm("dative", "sg"))

	table.insert(out, '|-')
	table.insert(out, '! ' .. small("gen."))
	table.insert(out, '| ' .. showForm("genitive", "sg"))

	-- Plural rows
	table.insert(out, '|-')
	table.insert(out, '! rowspan=4 | Plural')
	table.insert(out, '! ' .. small("nom."))
	table.insert(out, '| ' .. showForm("nominative", "pl"))

	table.insert(out, '|-')
	table.insert(out, '! ' .. small("acc."))
	table.insert(out, '| ' .. showForm("accusative", "pl"))

	table.insert(out, '|-')
	table.insert(out, '! ' .. small("dat."))
	table.insert(out, '| ' .. showForm("dative", "pl"))

	table.insert(out, '|-')
	table.insert(out, '! ' .. small("gen."))
	table.insert(out, '| ' .. showForm("genitive", "pl"))

	table.insert(out, '|}')
	return table.concat(out, '\n')
end

return export