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

มอดูล:ta-headword

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

local export = {}
local pos_functions = {}

local lang = require("Module:languages").getByCode("ta")
local script = require("Module:scripts").getByCode("Taml")
local PAGENAME = mw.title.getCurrentTitle().text

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 = {}, heads = {args["head"]}, inflections = {}}

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

	local letter = true
	local specialLetter = mw.ustring.gmatch(PAGENAME, '.-([ஃஜஶஷஸஹ]).-')
	while true do
		letter = specialLetter()
		if (not letter) then break end
		table.insert(data.categories, "ศัพท์ภาษาทมิฬที่สะกดด้วย " .. letter)
	end

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

end

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

	local plurals = {label = "plural"}

	if args["pl"] then
		table.insert(plurals, args["pl"])
		table.insert(data.inflections, plurals)
	end

end

pos_functions["คำสรรพนาม"] = function(args, data)

	local plurals = {label = "plural"}

	if args["pl"] then
		table.insert(plurals, args["pl"])
		table.insert(data.inflections, plurals)
	end

end

return export