ข้ามไปเนื้อหา

มอดูล:pa-headword

จาก วิกิพจนานุกรม พจนานุกรมเสรี

local export = {}
local pos_functions = {}

local lang = require("Module:languages").getByCode("pa")
local PAGENAME = mw.title.getCurrentTitle().text
local script = lang:findBestScript(PAGENAME) -- Guru or pa-Arab

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:th-utilities").th_pos(poscat)

	local data = {lang = lang, sc = script, pos_category = poscat_th, categories = {poscat_th .. "ภาษาปัญจาบใน" .. script:getCategoryName()}, heads = {args["head"] or PAGENAME}, genders = {}, inflections = {}}

	local mas = {label = "คู่ศัพท์เพศชาย"}
	if args["m"] then table.insert(mas, args["m"]) end
	if args["m2"] then table.insert(mas, args["m2"]) end
	if args["m3"] then table.insert(mas, args["m3"]) end
	if #mas > 0 then table.insert(data.inflections, mas) end

	local fem = {label = "คู่ศัพท์เพศหญิง"}
	if args["f"] then table.insert(fem, args["f"]) end
	if args["f2"] then table.insert(fem, args["f2"]) end
	if args["f3"] then table.insert(fem, args["f3"]) end
	if #fem > 0 then table.insert(data.inflections, fem) end

	local gur = {label = "คุรมุขี", lang = lang, sc = require("Module:scripts").getByCode("Guru")}
	if args["gur"] then table.insert(gur, args["gur"]) end
	if args["gur2"] then table.insert(gur, args["gur2"]) end
	if args["gur3"] then table.insert(gur, args["gur3"]) end
	if #gur > 0 then table.insert(data.inflections, gur) end

	local sha = {label = "ศาหมุขี", lang = lang, sc = require("Module:scripts").getByCode("pa-Arab")}
	if args["sha"] then table.insert(sha, args["sha"]) end
	if args["sha2"] then table.insert(sha, args["sha2"]) end
	if args["sha3"] then table.insert(sha, args["sha3"]) end
	if #sha > 0 then table.insert(data.inflections, sha) 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)

	local pls = {label = "พหูพจน์"}
	if args["pl"] then table.insert(pls, args["pl"]) end
	if args["pl2"] then table.insert(pls, args["pl2"]) end
	if args["pl3"] then table.insert(pls, args["pl3"]) end
	if #pls > 0 then table.insert(data.inflections, pls) end

	table.insert(data.genders, args["g"] or "?")

end

pos_functions["คำวิสามานยนาม"] = function(args, data)

	table.insert(data.genders, args["g"] or "?")

end

return export