模組:Nod-headword

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


local export = {}
local pos_functions = {}

local lang = require("Module:languages").getByCode("nod")
local PAGENAME = mw.title.getCurrentTitle().text
local script = lang:findBestScript(PAGENAME) -- Lana or Thai

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, categories = {"以" .. script:getCategoryName() .. "書寫的北部泰語" .. poscat}, heads = {args["head"] or PAGENAME}, translits = {args["tr"]}, 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 classifiers = {label = "量詞"}

	if args[1] then
		for _,par in ipairs(args) do
			if par == "*" then
				table.insert(classifiers, PAGENAME) -- shorthand
				table.insert(data.categories, "北部泰語量詞")
				table.insert(data.categories, "分類詞為「" .. PAGENAME .. "」的北部泰語名詞")
			else
				table.insert(classifiers, par)
				table.insert(data.categories, "分類詞為「" .. par .. "」的北部泰語名詞")
			end
		end
		table.insert(data.inflections, classifiers)
	end

end

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

	local par1 = args[1]; if par1 == "" then par1 = nil end
	local par2 = args[2]; if par2 == "" then par2 = nil end
	local par3 = args[3]; if par3 == "" then par3 = nil end
	local tlmode = require("Module:yesno")(args["tl"]) -- Is the Thai form transliterated?
	local abstract_forms = {label = "抽象名詞", accel = {pos = "noun", form = "abstract-noun"}}

	if par1 ~= "-" then
		if not par1 then
			if data.sc:getCode() == "Lana" then
				table.insert(abstract_forms, "ᨠᩣ᩠ᩁ" .. PAGENAME)
			else
				if tlmode then
					table.insert(abstract_forms, "การ" .. PAGENAME)
				else
					table.insert(abstract_forms, "ก๋าร" .. PAGENAME)
					table.insert(abstract_forms, "ก๋าน" .. PAGENAME)
				end
			end
		else
			if par1 == "~" then
				if data.sc:getCode() == "Lana" then
					table.insert(abstract_forms, "ᨠᩣ᩠ᩁ" .. PAGENAME)
					table.insert(abstract_forms, "ᨣᩤᩴ" .. PAGENAME) -- native
					table.insert(abstract_forms, "ᨤ᩠ᩅᩣ᩠ᨾ" .. PAGENAME)
				else
					if tlmode then
						table.insert(abstract_forms, "การ" .. PAGENAME)
						table.insert(abstract_forms, "คำ" .. PAGENAME) -- native
						table.insert(abstract_forms, "ฅวาม" .. PAGENAME)
					else
						table.insert(abstract_forms, "ก๋าร" .. PAGENAME)
						table.insert(abstract_forms, "ก๋าน" .. PAGENAME)
						table.insert(abstract_forms, "กำ" .. PAGENAME) -- native
						table.insert(abstract_forms, "ความ" .. PAGENAME)
					end
				end
			else
				table.insert(abstract_forms, par1)
				table.insert(abstract_forms, par2)
				table.insert(abstract_forms, par3)
			end
		end
		table.insert(data.inflections, abstract_forms)
	end

end

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

	local par1 = args[1]; if par1 == "" then par1 = nil end
	local par2 = args[2]; if par2 == "" then par2 = nil end
	local par3 = args[3]; if par3 == "" then par3 = nil end
	local tlmode = require("Module:yesno")(args["tl"]) -- Is the Thai form transliterated?
	local abstract_forms = {label = "抽象名詞", accel = {pos = "noun", form = "abstract-noun"}}

	if par1 ~= "-" then
		if not par1 then
			if data.sc:getCode() == "Lana" then
				table.insert(abstract_forms, "ᨣᩤᩴ" .. PAGENAME) -- native
				table.insert(abstract_forms, "ᨤ᩠ᩅᩣ᩠ᨾ" .. PAGENAME)
			else
				if tlmode then
					table.insert(abstract_forms, "คำ" .. PAGENAME) -- native
					table.insert(abstract_forms, "ฅวาม" .. PAGENAME)
				else
					table.insert(abstract_forms, "กำ" .. PAGENAME) -- native
					table.insert(abstract_forms, "ความ" .. PAGENAME)
				end
			end
		else
			table.insert(abstract_forms, par1)
			table.insert(abstract_forms, par2)
			table.insert(abstract_forms, par3)
		end
		table.insert(data.inflections, abstract_forms)
	end

end

-- same logic
pos_functions["副詞"] = pos_functions["形容詞"]

return export