模組:Aot-headword

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


local export = {}
local pos_functions = {}

local lang = require("Module:languages").getByCode("aot")
local PAGENAME = mw.title.getCurrentTitle().text
local script = lang:findBestScript(PAGENAME) -- Latn or Beng

function export.show(frame)

	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 data = {lang = lang, sc = script, pos_category = poscat, sccat = true, categories = {}, heads = {args["head"] or PAGENAME}, translits = {args["tr"]}, inflections = {}}

	local beng = {label = "孟加拉文", lang = lang, sc = require("Module:scripts").getByCode("Beng")}
	if args[1] then table.insert(beng, args[1]) end
	if args[2] then table.insert(beng, args[2]) end
	if args[3] then table.insert(beng, args[3]) end
	if args[4] then table.insert(beng, args[4]) end
	if #beng > 0 then table.insert(data.inflections, beng) end

	if pos_functions[poscat] then
		pos_functions[poscat](args, data)
	end

	return require("Module:headword").full_headword(data)

end

pos_functions["動詞"] = function(args, data)

	--verb is always prefix
	data.heads[1] = data.heads[1] .. "-"

end

pos_functions["分類詞"] = function(args, data)

	--classifier is always prefix
	data.heads[1] = data.heads[1] .. "-"

end

pos_functions["形容詞"] = function(args, data)

	--adjective can be either type 1 or type 2
	if args["t"] ~= "1" and args["t"] ~= "2" then
		args["t"] = "?"
	end

	--adjective type 1 is prefix
	if args["t"] == "1" then
		data.heads[1] = data.heads[1] .. "-"
	end
	table.insert(data.inflections, {label = "type " .. args["t"]})

end

return export