Jump to content

Module:sei-noun

From Wiktionary, the free dictionary

This module implements {{sei-decl-rel}}. Its usage will be expanded in the future.


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

local export = {}

-- Make the table
local function make_table(data)
	local function repl(param)
		local forms = data.forms[param]
		
		if not forms then
			return "—"
		end

		local ret = {}
		
		for key, subform in ipairs(forms) do
			table.insert(ret, require("Module:links").full_link({lang = lang, term = subform}))
		end
		
		return table.concat(ret, "<br/>")
	end

	local wikicode = mw.getCurrentFrame():expandTemplate{ 
		title = 'inflection-table-top', 
		args = {
			title = mw.getContentLanguage():ucfirst(data.info or ""),
			palette = 'blue',
			tall = 'yes',
		}
	} .. [=[
! 
! singular
! plural
|-
! absolutive
| data-accel-col="2" | {{{absv|s}}}
| data-accel-col="3" | {{{absv|p}}}
|-
! 1st person
| data-accel-col="2" | {{{first|s}}}
| data-accel-col="3" | {{{first|p}}}
|-
! 2nd person
| data-accel-col="2" | {{{second|s}}}
| data-accel-col="3" | {{{second|p}}}
|-
! 3rd person
| data-accel-col="2" | {{{third|s}}}
| data-accel-col="3" | {{{third|p}}}
]=] .. mw.getCurrentFrame():expandTemplate{ title = 'inflection-table-bottom' }

	return mw.ustring.gsub(wikicode, "{{{[#!]?([a-z0-9|]+)}}}", repl) .. require("Module:utilities").format_categories(data.categories, lang)
end

-- Inflection functions (common nouns)

function export.relative(frame)
	local args = frame:getParent().args
		
	local data = {
		forms = {},
		info = "Declension of ",
		categories = {},
	}
	
	-- add the base singular/plural forms
	local base

	if args[1] then
		base = args[1]
	elseif args["3s"] then
		base = args["3s"]
	else
		base = mw.title.getCurrentTitle().text
	end

	data.info = data.info .. require("Module:links").full_link({lang = lang, alt = base}, "term")

	--absolutive forms
	if args["a"] then
		data.forms["absv|s"] = {args["a"]}
	end
	if args["ap"] then
		data.forms["absv|p"] = {args["ap"]}
	end
	
	--First person forms
	if args["1s"] then
		data.forms["first|s"] = {args["1s"]}
	end
	if args["1p"] then
		data.forms["first|p"] = {args["1p"]}
	end
	
	--Second person forms
	if args["2s"] then
		data.forms["second|s"] = {args["2s"]}
	end
	if args["2p"] then
		data.forms["second|p"] = {args["2p"]}
	end
	
	--Third person forms
	if args["3p"] then
		data.forms["third|p"] = {args["3p"]}
	end
	data.forms["third|s"] = {base}
	
	return make_table(data)
end

return export