跳转到内容

模組:Nap-headword

維基詞典,自由的多語言詞典


local export = {}
local pos_functions = {}

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

function export.show(frame)
	args = frame:getParent().args
	local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
	
	local head = args["head"]; if head == "" then head = nil end
	
	local data = {lang = lang, pos_category = poscat, categories = {}, heads = {head}, inflections = {}}
	
	if pos_functions[poscat] then
		pos_functions[poscat](args, data)
	end
 
	return require("Module:headword").full_headword(data)
end

pos_functions["形容詞"] = function(args, data)
	local arg1 = args[1]
	local arg2 = args[2]
	local arg3 = args[3]
	
	if arg3 then
		table.insert(data.inflections,{label = "陰性單數", arg1, accel = {form = "f|s"}})
		table.insert(data.inflections,{label = "陽性複數", arg2, accel = {form = "m|p"}})
		table.insert(data.inflections,{label = "陰性複數", arg3, accel = {form = "f|p"}})
	elseif arg2 then
		table.insert(data.inflections,{label = "陰性單數", arg1, accel = {form = "f|s"}})
		table.insert(data.inflections,{label = "複數", arg2, accel = {form = "p"}})
	elseif arg1 then
		table.insert(data.inflections,{label = "複數", arg1, accel = {form = "p"}})
	else
		PAGENAME = mw.title.getCurrentTitle().text
		if mw.ustring.sub(PAGENAME,-1) == 'o' then
			table.insert(data.inflections,{label = "陰性單數", mw.ustring.sub(PAGENAME,1,-2)..'a', accel = {form = "f|s"}})
			
			if mw.ustring.sub(PAGENAME,-3) == 'cio' or mw.ustring.sub(PAGENAME,-3) == 'gio' then
				table.insert(data.inflections,{label = "複數", mw.ustring.sub(PAGENAME,1,-3)..'e', accel = {form = "p"}})
			elseif mw.ustring.sub(PAGENAME,-2) == 'co' or mw.ustring.sub(PAGENAME,-2) == 'go' then
				table.insert(data.inflections,{label = "複數", mw.ustring.sub(PAGENAME,1,-2)..'he', accel = {form = "p"}})
			else
				table.insert(data.inflections,{label = "複數", mw.ustring.sub(PAGENAME,1,-2)..'e', accel = {form = "p"}})
			end
		elseif mw.ustring.sub(PAGENAME,-1) == 'e' then
			table.insert(data.inflections,{label = "複數", "{{{p}}}"})
		end
	end
end

return export