বিষয়বস্তুতে চলুন

মডিউল:osx-decl-adj

উইকিঅভিধান, মুক্ত অভিধান থেকে

এই মডিউলের জন্য মডিউল:osx-decl-adj/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local export = {}

local m_links = require("Module:links")
local m_utils = require("Module:utilities")

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

local headers = {}

headers.strong = [=[
|- 
! colspan="7" | Strong declension
]=]

headers.weak = [=[
|- 
! colspan="7" | Weak declension
]=]

headers.top = function(text)
	return mw.getCurrentFrame():expandTemplate{ 
		title = 'inflection-table-top', 
		args = {
			title = text,
			palette = 'yellow',
			tall = 'yes',
			class = 'wide', -- there seem to be loads of alternative forms in osx
		}
	}
end

local decl_data = {}

decl_data["st"] = {}
setmetatable(decl_data["st"], {__call = function(self, stem, data)
	
	data.forms["nom_sg_m"] = {stem}
	data.forms["nom_sg_f"] = {stem}
	data.forms["nom_sg_n"] = {stem}
	data.forms["nom_pl_m"] = {stem .. "e", stem .. "a"}
	data.forms["nom_pl_f"] = {stem .. "a"}
	data.forms["nom_pl_n"] = {stem, stem .. "a"}

	data.forms["acc_sg_m"] = {stem .. "an", stem .. "en"}
	data.forms["acc_sg_f"] = {stem .. "a"}
	data.forms["acc_sg_n"] = {stem}
	data.forms["acc_pl_m"] = {stem .. "a", stem .. "e"}
	data.forms["acc_pl_f"] = {stem .. "a"}
	data.forms["acc_pl_n"] = {stem, stem .. "a"}
	
	data.forms["gen_sg_m"] = {stem .. "es", stem .. "as"}
	data.forms["gen_sg_f"] = {stem .. "ara", stem .. "aro"}
	data.forms["gen_sg_n"] = {stem .. "es", stem .. "as"}
	data.forms["gen_pl_m"] = {stem .. "aro", stem .. "oro", stem .. "ero"}
	data.forms["gen_pl_f"] = {stem .. "aro", stem .. "oro", stem .. "ero"}
	data.forms["gen_pl_n"] = {stem .. "aro", stem .. "oro", stem .. "ero"}
	
	data.forms["dat_sg_m"] = {stem .. "umu", stem .. "um", stem .. "un", stem .. "un", stem .. "on", stem .. "en", stem .. "an"}
	data.forms["dat_sg_f"] = {stem .. "aro", stem .. "aru", stem .. "ara"}
	data.forms["dat_sg_n"] = {stem .. "umu", stem .. "um", stem .. "un", stem .. "un", stem .. "on", stem .. "en", stem .. "an"}
	data.forms["dat_pl_m"] = {stem .. "un", stem .. "on", stem .. "um"}
	data.forms["dat_pl_f"] = {stem .. "un", stem .. "on"}
	data.forms["dat_pl_n"] = {stem .. "un", stem .. "on", stem .. "um"}

	return data
end
})

decl_data["wk"] = {}
setmetatable(decl_data["wk"], {__call = function(self, stem, data)
	
	data.forms["nom_sg_m"] = {stem .. "o", stem .. "a"}
	data.forms["nom_sg_f"] = {stem .. "a", stem .. "e"}
	data.forms["nom_sg_n"] = {stem .. "a", stem .. "e"}
	data.forms["nom_pl_m"] = {stem .. "on", stem .. "un"}
	data.forms["nom_pl_f"] = {stem .. "on", stem .. "un", stem .. "an"}
	data.forms["nom_pl_n"] = {stem .. "on", stem .. "un"}

	data.forms["acc_sg_m"] = {stem .. "on", stem .. "an"}
	data.forms["acc_sg_f"] = {stem .. "un", stem .. "on", stem .. "an"}
	data.forms["acc_sg_n"] = {stem .. "a", stem .. "e"}
	data.forms["acc_pl_m"] = {stem .. "on", stem .. "un"}
	data.forms["acc_pl_f"] = {stem .. "on", stem .. "un", stem .. "an"}
	data.forms["acc_pl_n"] = {stem .. "on", stem .. "un"}
	
	data.forms["gen_sg_m"] = {stem .. "en", stem .. "an"}
	data.forms["gen_sg_f"] = {stem .. "un", stem .. "an", stem .. "en"}
	data.forms["gen_sg_n"] = {stem .. "en", stem .. "an"}
	data.forms["gen_pl_m"] = {stem .. "ono", stem .. "eno"}
	data.forms["gen_pl_f"] = {stem .. "ono"}
	data.forms["gen_pl_n"] = {stem .. "ono", stem .. "eno"}

	data.forms["dat_sg_m"] = {stem .. "on", stem .. "en", stem .. "an"}
	data.forms["dat_sg_f"] = {stem .. "un", stem .. "an"}
	data.forms["dat_sg_n"] = {stem .. "on", stem .. "en", stem .. "an"}
	data.forms["dat_pl_m"] = {stem .. "on", stem .. "un"}
	data.forms["dat_pl_f"] = {stem .. "on", stem .. "un"}
	data.forms["dat_pl_n"] = {stem .. "on", stem .. "un"}
	
	return data
end
})

function insert_all(tb, args)
	for _, v in ipairs(args) do
		table.insert(tb, v)
	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
	
	local data = {forms = {}, categories = {}}
	
	data.head = parent_args["head"] or nil
	
	-- Override for templates
	if not parent_args[1] then
		setmetatable(parent_args, {__index = function(self, key)
			return "{{{" .. key .. "}}}"
		end
		})
	end
	
	local separator = '|-\n| class="separator" colspan="999" |\n'
	local footer = frame:expandTemplate{ title = 'inflection-table-bottom' }

	local wikicode = {}
	
	if parent_args.decl == "st" then
		-- do nothing yet
	else
		if parent_args[1] ~= "" then
			insert_all(wikicode, {headers.top("Positive forms of " .. parent_args[1]), headers.strong,
				make_base_table(decl_data.st(parent_args[1], data)), separator,
				headers.weak, make_base_table(decl_data.wk(parent_args[1], data)),
				footer})
		end
		if parent_args[2] and parent_args[2] ~= "" then
			insert_all(wikicode, {headers.top("Comparative forms of " .. parent_args[1] .. " (weak only)"), 
				headers.weak, make_base_table(decl_data.wk(parent_args[2], data)),
				footer})
		end
		if parent_args[3] and parent_args[3] ~= "" then
			insert_all(wikicode, {headers.top("Superlative forms of " .. parent_args[1]), headers.strong,
				make_base_table(decl_data.st(parent_args[3], data)), separator,
				headers.weak, make_base_table(decl_data.wk(parent_args[3], data)),
				footer})
		end
	end

	-- Make the table
	return table.concat(wikicode)
end


local function show_form(form)
	if not form then
		return "—"
	end
	
	local ret = {}
	
	for key, subform in ipairs(form) do
		if mw.title.getCurrentTitle().nsText == "Reconstruction" and subform ~= "—" then
			subform = "*" .. subform
		end
		table.insert(ret, m_links.full_link({lang = lang, term = subform}))
	end
		
	return table.concat(ret, ", ")
end

function make_base_table(data)
	local function repl(param)
		if param == "decl_type" then
			return data.decl_type
		else
			return show_form(data.forms[param])
		end
	end

	local wikicode = [=[
|-
! class="outer" | 
! colspan="3" class="outer" | singular
! colspan="3" class="outer" | plural
|-
!
! masculine
! feminine
! neuter
! masculine
! feminine
! neuter
|-
! nominative
| {{{nom_sg_m}}}
| {{{nom_sg_f}}}
| {{{nom_sg_n}}}
| {{{nom_pl_m}}}
| {{{nom_pl_f}}}
| {{{nom_pl_n}}}
|-
! accusative
| {{{acc_sg_m}}}
| {{{acc_sg_f}}}
| {{{acc_sg_n}}}
| {{{acc_pl_m}}}
| {{{acc_pl_f}}}
| {{{acc_pl_n}}}
|-
! genitive
| {{{gen_sg_m}}}
| {{{gen_sg_f}}}
| {{{gen_sg_n}}}
| {{{gen_pl_m}}}
| {{{gen_pl_f}}}
| {{{gen_pl_n}}}
|-
! dative
| {{{dat_sg_m}}}
| {{{dat_sg_f}}}
| {{{dat_sg_n}}}
| {{{dat_pl_m}}}
| {{{dat_pl_f}}}
| {{{dat_pl_n}}}
]=]

	local ret = mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)
	return ret
end

return export