Pergi ke kandungan

Modul:id-headword

Daripada Wikikamus
local export = {}
local pos_functions = {}

local lang = require("Module:languages").getByCode("id")
local script = require('Module:scripts').getByCode("Latn")
local PAGENAME = mw.title.getCurrentTitle().text

function export.show(frame)
	-- FIXME: Use [[Module:parameters]].
	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 head = args["head"]; if head == "" then head = nil end
	
	local data = {lang = lang, sc = script, pos_category = poscat, categories = {}, heads = {head}, translits = {"-"}, inflections = {}}
	
	if pos_functions[poscat] then
		pos_functions[poscat](args, data)
	end

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

end

pos_functions["kata nama"] = function(args, data)

	local pl = {label = "jamak"}
	if args["pl"] == nil then
		table.insert(data.categories, "Permintaan bentuk jamak entri bahasa Indonesia")
	else
		if args["pl"] == "-" then
			table.insert(data.categories, "Kata nama tidak berbilang bahasa Indonesia")
		else
			if args["pl"] == "kata ganda" then
				-- common plural
				local subwords = mw.text.split(PAGENAME, "%s")
				local firstword = subwords[1]
				subwords[1] = mw.ustring.gsub("[[" .. firstword .. "]]-[[" .. firstword .. "]]", "([a-z]+%-)%1%1", "banyak %1") -- reduplicate only first word
				table.insert(pl, table.concat(subwords, " "))
			else
				table.insert(pl, args["pl"]) -- this is also used for 'para' type
				if args["pl2"] then table.insert(pl, args["pl2"]) end
				if args["pl3"] then table.insert(pl, args["pl3"]) end
			end
			table.insert(data.inflections, pl)
		end
	end

end

pos_functions["kata nama khas"] = function(args, data)

	local pl = {label = "plural"}
	-- not necessary to have plural(s)
	if args["pl"] then table.insert(pl, args["pl"]) end
	if args["pl2"] then table.insert(pl, args["pl2"]) end
	if args["pl3"] then table.insert(pl, args["pl3"]) end
	if #pl > 0 then table.insert(data.inflections, pl) end

end

pos_functions["kata sifat"] = function(args, data)

end

return export