มอดูล: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 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}, inflections = {}}

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

	local content = mw.title.new(PAGENAME):getContent()
	local diacritics = mw.ustring.match(content, '.-([iyɨʉɯuɪʏʊeøɘɵɤoəɛœɜɞʌɔæɐaɶɑɒ][̡̢̧̨᷎̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̳᷂᷊᷏̀́̂̃̄̅̆̇̈̉̊̋̌̍̎̏̐̑̒̓̔᷀᷁᷃᷄᷅᷆᷇᷈᷉᷋᷌̕᷍]).-')
	local nodAltTemplate = mw.ustring.match(content, "{{nod%-alt")
	local TaiThamTransliteration = mw.ustring.match(content, '.-([ᨠ-᪭]).-')

	local oldToneBars2 = mw.ustring.match(content, "[ptkbdt͡ɕʔmnɲŋfsxhjlwːiɯueɤoɛaɔʰ]˩")
	local oldToneBars3 = mw.ustring.match(content, "˥˧")
	local oldToneBars4v1 = mw.ustring.match(content, "[ptkbdt͡ɕʔmnɲŋfsxhjlwːiɯueɤoɛaɔʰ][^˨]˦/")
	local oldToneBars4v2 = mw.ustring.match(content, "[ptkbdt͡ɕʔmnɲŋfsxhjlwːiɯueɤoɛaɔʰ][^˨]˦%.")
	local oldToneBars5 = mw.ustring.match(content, "˥˩")
	local oldToneBars6 = mw.ustring.match(content, "˦˥˦")
	

	if diacritics then
		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่ใช้เครื่องหมายเสริมสัทอักษร")
	end
	if mw.ustring.match(PAGENAME, '.-([ᨠ-᪭]).-') and not nodAltTemplate then
		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่ไม่มี nod-alt")
	end
	if mw.ustring.match(PAGENAME, '.-([ก-๛]).-') and not TaiThamTransliteration then
		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่ไม่มีรูปแบบอื่นในอักษรไทธรรม")
	end

	if oldToneBars2 or oldToneBars3 or oldToneBars4v1 or oldToneBars4v2 or oldToneBars5 or oldToneBars6 then	
		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่ต้องแก้การถ่ายเสียงวรรณยุกต์")	
	end --จะลบออกเมื่อแก้เสร็จ

	if mw.ustring.match(PAGENAME, "ᩮ᩠ᨿ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩮ᩠᩵ᨿ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩮ᩠᩶ᨿ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩵ᩮ᩠ᨿ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩶ᩮ᩠ᨿ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩠᩵ᨿ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩠᩶ᨿ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩫ᩠ᩅ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩫ᩠᩵ᩅ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩫ᩠᩶ᩅ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩠᩵ᩅ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩠᩶ᩅ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩮᩥᩬ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩮᩥ᩵ᩬ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩮᩥ᩶ᩬ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩴᩣ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩴᩤ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩵ᩴᩣ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩵ᩴᩤ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩶ᩴᩣ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩶ᩴᩤ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩴᩬ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩴ᩵ᩬ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "ᩴ᩶ᩬ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩵ᩬ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	end
	if mw.ustring.match(PAGENAME, "᩶ᩬ") then		table.insert(data.categories, "ศัพท์ภาษาคำเมืองที่อาจไม่ได้สะกดตามหลักยูนิโค้ด")	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 = {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 = {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