このモジュールについての説明文ページを モジュール:km-headword/doc に作成できます

local export = {}
local pos_functions = {}

local lang = require("モジュール:languages").getByCode("km")
local script = require('モジュール:scripts').getByCode("Khmr")
local PAGENAME = mw.title.getCurrentTitle().text
local pron = require("モジュール:km-pron")

function export.show(frame)

	local args = frame:getParent().args
	local poscat = frame.args[1] or error("品詞が指定されていません。 モジュール呼び出しにパラメータ 1 を渡してください。")
	
	local data = {lang = lang, sc = script, pos_category = poscat, categories = {}, heads = {args["head"]}, inflections = {}}
	
	if args["cat2"] then
		table.insert(data.categories, "クメール語 " .. args["cat2"])
	end
	if args["cat3"] then
		table.insert(data.categories, "クメール語 " .. args["cat3"])
	end
	
	if pos_functions[poscat] then
		pos_functions[poscat](args, data)
	end
	
	local phon
	local content = mw.title.new(PAGENAME):getContent()
	local code = mw.ustring.match(content, '{{km%-IPA[^}]*}}')
	local false_positive = mw.ustring.match(content, 'obsolete spelling of') or mw.ustring.match(content, 'obsolete form of') or mw.ustring.match(content, 'alternative spelling of') or mw.ustring.match(content, 'archaic spelling of') or mw.ustring.match(PAGENAME, 'Unsupported')

	if not code then
		phon = args["phon"] or args["mono"] or ""
		if phon ~= "" then
			data.translits = {pron.convert(phon, "tc")}
		elseif args["tr"] then
			data.translits = { args["tr"] }
		else
			data.translits = { (lang:transliterate(PAGENAME)) }
		end
		if not false_positive then
			table.insert(data.categories, "クメール テンプレート:km-IPAなし")
		end
	else
		phon = args["phon"] or args["mono"] or mw.ustring.match(code, '|([^|}]+)') or PAGENAME -- detects only first one
		data.translits = {pron.convert(phon, "tc")}
	end
	
	local letter = true
	local specialLetter = mw.ustring.gmatch(PAGENAME, '.-([ឋឌឍឝឞឡឥ-ឳៗ៉៊៌៍៏័េ]).-')
	while true do
		letter = specialLetter()
		if (not letter) then break end
		if letter == "៉" or letter == "៊" or letter == "៌" or letter == "៍" or letter == "៏" or letter == "័" then
			table.insert(data.categories, "クメール語 文字◌" .. letter .."を含む語") -- add dotted circle for above/below marks
		else
			table.insert(data.categories, "クメール語 文字" .. letter .."を含む語")
		end
	end
	
	return require("モジュール:headword").full_headword(data)

end

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

	local classifiers = {label = "classifier"}

	if args[1] then
		for _,par in ipairs(args) do
			if par == "*" then
				table.insert(classifiers, PAGENAME) -- shorthand
				table.insert(data.categories, "クメール語 classifiers")
				table.insert(data.categories, "クメール語 nouns classified by " .. PAGENAME)
			else
				table.insert(classifiers, par)
				table.insert(data.categories, "クメール語 nouns classified by " .. 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 abstract_forms = {label = "抽象名詞", accel = {pos = "noun", form = "abstract-noun"}}

	if par1 ~= "-" then
		if not par1 then
			table.insert(abstract_forms, "ការ" .. PAGENAME)
		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

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 abstract_forms = {label = "抽象名詞", accel = {pos = "noun", form = "abstract-noun"}}

	if par1 ~= "-" then
		if not par1 then
			table.insert(abstract_forms, "ភាព" .. PAGENAME)
		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

return export