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

মডিউল:dum-adjectives

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

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

local m_links = require("Module:links")
local m_common = require("Module:dum-common")

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

local export = {}


function export.show(frame)
	local params = {
		[1] = {required = true, default = "{{{1}}}"},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local data = {forms = {}, info = "adjective", categories = {}}
	
	local stem = mw.ustring.gsub(args[1], "([^aeiouâêîôûāēōë])e$", "%1")
	
	data.forms["m_nom_indf"] = {m_common.devoiced(m_common.checked(args[1]))}
	data.forms["m_nom_defn"] = {stem .. "e"}
	data.forms["m_acc"] = {stem .. "en"}
	data.forms["m_gen"] = {m_common.devoiced(m_common.checked(stem)) .. "s"}
	data.forms["m_dat"] = {stem .. "en"}
	
	data.forms["f_nom"] = {stem .. "e"}
	data.forms["f_acc"] = {stem .. "e"}
	data.forms["f_gen"] = {stem .. "er"}
	data.forms["f_dat"] = {stem .. "er"}
	
	data.forms["n_nom_indf"] = {m_common.devoiced(m_common.checked(args[1]))}
	data.forms["n_nom_defn"] = {stem .. "e"}
	data.forms["n_acc_indf"] = {m_common.devoiced(m_common.checked(args[1]))}
	data.forms["n_acc_defn"] = {stem .. "e"}
	data.forms["n_gen"] = {m_common.devoiced(m_common.checked(stem)) .. "s"}
	data.forms["n_dat"] = {stem .. "en"}
	
	data.forms["p_nom"] = {stem .. "e"}
	data.forms["p_acc"] = {stem .. "e"}
	data.forms["p_gen"] = {stem .. "er"}
	data.forms["p_dat"] = {stem .. "en"}
	
	return make_table(data)
end


-- Make the table
function make_table(data)
	local function repl(param)
		if param == "info" then
			return mw.getContentLanguage():ucfirst(data.info or "")
		end
		
		local form = data.forms[param]
		
		if not form or #form == 0 then
			return "—"
		end
		
		local ret = {}
		
		for key, subform in ipairs(form) do
			table.insert(ret, m_links.full_link({lang = lang, alt = subform}))
		end
		
		return table.concat(ret, ", ")
	end
	
	local names = {
		["m"] = "পুরুষবাচক",
		["f"] = "নারীবাচক",
		["n"] = "neuter",
		
		["nom"] = "nominative",
		["acc"] = "accusative",
		["gen"] = "genitive",
		["dat"] = "dative",
		
		["s"] = "singular",
		["p"] = "plural",
		
		["indf"] = "indefinite",
		["defn"] = "definite",
	}
	
	local cases = {"nom", "acc", "gen", "dat"}
	local genders = {"m", "f", "n", "p"}
	local defns = {"indf", "defn"}
	
	local wikicode = {}
	
	table.insert(wikicode, "{| class=\"inflection-table vsSwitcher\" data-toggle-category=\"inflection\" style=\"border: 1px solid #CCCCFF;\" cellspacing=\"1\" cellpadding=\"3\"")
	table.insert(wikicode, "|- style=\"background: #CCCCFF;\"")
	table.insert(wikicode, "! class=\"vsToggleElement\" style=\"text-align: left; min-width: " .. tostring(8 + 6 + 12 * #genders) .. "em;\" colspan=\"" .. tostring(#genders + 2) .. "\" | {{{info}}}")
	
	table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #CCCCFF;\"")
	table.insert(wikicode, "| style=\"background: #E6E6FF;\" colspan=\"2\" |")
	
	for _, g in ipairs(genders) do
		table.insert(wikicode, "! style=\"background: #CCCCFF; min-width: 12em;\" | " .. mw.getContentLanguage():ucfirst(names[g]))
	end
	
	for _, case in ipairs(cases) do
		if case == "nom" then
			for i, d in ipairs(defns) do
				table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
				
				if i == 1 then
					table.insert(wikicode, "! style=\"background: #CCCCFF; min-width: 8em;\" rowspan=\"" .. tostring(#defns) .. "\" | " .. mw.getContentLanguage():ucfirst(names[case]))
				end
				
				table.insert(wikicode, "! style=\"background: #CCCCFF; min-width: \" | " .. mw.getContentLanguage():ucfirst(names[d]))
				
				for _, g in ipairs(genders) do
					if g == "m" or g == "n" then
						table.insert(wikicode, "| {{{" .. g .. "_" .. case .. "_" .. d .. "}}}")
					elseif i == 1 then
						table.insert(wikicode, "| rowspan=\"" .. tostring(#defns) .. " | {{{" .. g .. "_" .. case .. "}}}")
					end
				end
			end
		else
			if case == "acc" then
			for i, d in ipairs(defns) do
				table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
				
				if i == 1 then
					table.insert(wikicode, "! style=\"background: #CCCCFF; min-width: 8em;\" rowspan=\"" .. tostring(#defns) .. "\" | " .. mw.getContentLanguage():ucfirst(names[case]))
				end
				
				table.insert(wikicode, "! style=\"background: #CCCCFF; min-width: \" | " .. mw.getContentLanguage():ucfirst(names[d]))
				
				for _, g in ipairs(genders) do
					if g == "n" then
						table.insert(wikicode, "| {{{" .. g .. "_" .. case .. "_" .. d .. "}}}")
					elseif i == 1 then
						table.insert(wikicode, "| rowspan=\"" .. tostring(#defns) .. " | {{{" .. g .. "_" .. case .. "}}}")
					end
				end
			end
			
			else
				table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #F2F2FF;\"")
				table.insert(wikicode, "! style=\"background: #CCCCFF;\" colspan=\"2\" | " .. mw.getContentLanguage():ucfirst(names[case]))
			
				for _, g in ipairs(genders) do
					table.insert(wikicode, "| {{{" .. g .. "_" .. case .. "}}}")
				end
			end
		end
	end
	
	table.insert(wikicode, "|}")
	
	wikicode = table.concat(wikicode, "\n")
	
	return (mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. require("Module:utilities").format_categories(data.categories, lang)
end

return export