コンテンツにスキップ

モジュール:lo-headword

出典: フリー多機能辞典『ウィクショナリー日本語版(Wiktionary)』

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

local export = {}
local pos_functions = {}

local lang = require("モジュール:languages").getByCode("lo")
local script = require("モジュール:scripts").getByCode("Laoo")
local PAGENAME = mw.title.getCurrentTitle().text

function export.show(frame)

	local args = frame:getParent().args
	local poscat = frame.args[1] or error("品詞が指定されていません。引数1をモジュールの呼び出しに渡して下さい。")
	
	local head = args["head"] or PAGENAME
	local tr = args["tr"]
	
	local data = {
		lang = lang,
		pos_category = poscat,
		categories = {},
		heads = {head},
		translits = {tr},
		inflections = {}
	}
	
	if pos_functions[poscat] then
		pos_functions[poscat](args, data)
	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 == "໋" then
			table.insert(data.categories, "ラーオ語 文字◌" .. letter .. "を含む語") -- add dotted circle for above/below marks
		else
			table.insert(data.categories, "ラーオ語 文字" .. letter .. "を含む語")
		end
	end
	if mw.ustring.match(PAGENAME, '.-([^ຫ]ຼ).-') then
		table.insert(data.categories, "ラーオ語 文字ຫຼ以外で用いられる文字◌ຼを含む語")
	end

	return require("モジュール: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 abstract_forms = {label = "抽象名詞", accel = {form = "abstract-noun"}}

	if par1 ~= "-" then
		if not par1 then
			table.insert(abstract_forms, "ການ" .. PAGENAME)
		else
			if par1 == "~" then
				table.insert(abstract_forms, "ການ" .. PAGENAME)
				table.insert(abstract_forms, "ຄວາມ" .. PAGENAME)
			else
				table.insert(abstract_forms, par1)
				table.insert(abstract_forms, par2)
			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 abstract_forms = {label = "抽象名詞", accel = {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)
		end
		table.insert(data.inflections, abstract_forms)
	end

end

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

return export