Bước tới nội dung

Mô đun:got-headword

Từ điển mở Wiktionary
local export = {}
local pos_functions = {}

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

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	PAGENAME = mw.title.getCurrentTitle().text
	local 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 cat = args["cat"]; if cat == "" then cat = nil end
	local cat2 = args["cat2"]; if cat2 == "" then cat2 = nil end
	local cat3 = args["cat3"]; if cat3 == "" then cat3 = nil end
	
	local head = args["head"]; if head == "" then head = nil end
	local tr = args["tr"]; if tr == "" then tr = nil end
	
	local data = {lang = lang, pos_category = cat or poscat, categories = {}, heads = {head}, translits = {tr}, genders = {}, inflections = {}}
	
	if cat2 then table.insert(data.categories, "Gothic " .. cat2) end
	if cat3 then table.insert(data.categories, "Gothic " .. cat3) end
	
	if pos_functions[poscat] then
		pos_functions[poscat](args, data)
	end
	
	return require("Module:headword").full_headword(data)
end

pos_functions["Danh từ"] = function(args, data)
	-- Iterate over all gn parameters (g2, g3 and so on) until one is empty
	local g = args[1] or ""; if g == "" then g = "?" end
	local i = 2
	
	while g ~= "" do
		-- If any of the specifications is a "?", add the entry
		-- to a cleanup category.
		if g == "m-p" or g == "f-p" or g == "n-p" then
			table.insert(data.categories, "Gothic pluralia tantum")
		end
		
		table.insert(data.genders, g)
		g = args["g" .. i] or ""
		i = i + 1
	end
	
	if #data.genders == 0 then
		table.insert(data.genders, "?")
	end
end

pos_functions["proper nouns"] = pos_functions["nouns"]

pos_functions["Tính từ"] = function(args, data)
	local adverb = args["adv"]; if adverb == "" then adverb = nil end
	local comparative = args[1]; if comparative == "" then comparative = nil end
	local superlative = args[2]; if superlative == "" then superlative = nil end
	
	if adverb then
		table.insert(data.inflections, {label = "adverb", adverb})
	end
	
	if comparative then
		table.insert(data.inflections, {label = "comparative", comparative})
	end
	
	if superlative then
		table.insert(data.inflections, {label = "superlative", superlative})
	end
end

pos_functions["adverbs"] = function(args, data)
	local adjective = args["adj"]; if adjective == "" then adjective = nil end
	local comparative = args[1]; if comparative == "" then comparative = nil end
	local superlative = args[2]; if superlative == "" then superlative = nil end
	
	if adjective then
		table.insert(data.inflections, {label = "adjective", adjective})
	end
	
	if comparative then
		table.insert(data.inflections, {label = "comparative", comparative})
	end
	
	if superlative then
		table.insert(data.inflections, {label = "superlative", superlative})
	end
end

return export