มอดูล: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 poscat_th = require("Module:utilities").translate_term(poscat)

	local data = {lang = lang, sc = script, pos_category = poscat_th, categories = {poscat_th .. "ภาษาอะตงใน" .. script:getCategoryName()}, 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_th] then
		pos_functions[poscat_th](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 = "ชนิดที่ " .. args["t"]})

end

return export