A modult a Modul:tl-headword/doc lapon tudod dokumentálni

local export = {}
local pos_functions = {}

local lang = require("Module:languages").getByCode("tl")
local PAGENAME = mw.title.getCurrentTitle().text
local script = require("Module:scripts").findBestScript(PAGENAME, lang) -- Latn or Tglg

function export.show(frame)

	local tracking_categories = {}

	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 = {} -- supports multiple headword
	if args["head"] or args[1] then table.insert(head, args["head"] or args[1]) end
	if args["head2"] or args[2] then table.insert(head, args["head2"] or args[2]) end
	if args["head3"] or args[3] then table.insert(head, args["head3"] or args[3]) end

	local data = {lang = lang, sc = script, pos_category = poscat, categories = {}, heads = head, translits = {"-"}, inflections = {}}
	
	local baybayin = {label = "Baybayin spelling"}
	local sc_Tglg = require("Module:scripts").getByCode("Tglg")
	if args["b"] then table.insert(baybayin, { term = args["b"], sc = sc_Tglg }) end
	if args["b2"] then table.insert(baybayin, { term = args["b2"], sc = sc_Tglg }) end
	if args["b3"] then table.insert(baybayin, { term = args["b3"], sc = sc_Tglg }) end
	if #baybayin > 0 then table.insert(data.inflections, baybayin) end

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

	local content = mw.title.new(PAGENAME):getContent()
	local code = content and mw.ustring.match(content, "{{tl%-IPA[^}]*}}")

	if script:getCode() == "Latn" and not code then
		table.insert(tracking_categories, "Tagalog terms without tl-IPA template")
	end

	return require("Module:headword").full_headword(data) .. require("Module:utilities").format_categories(tracking_categories, lang)

end

local conjugation_types = {
	["actor I"] = {"1st actor trigger", "Tagalog 1st actor focus verbs"},
	["actor II"] = { "2nd actor trigger", "Tagalog 2nd actor trigger verbs" },
	["actor III"] = { "3rd actor trigger", "Tagalog 3rd actor trigger verbs" },
	["actor IV"] = { "4th actor trigger", "Tagalog 4th actor trigger verbs" },
	["actor V"] = { "5th actor trigger", "Tagalog 5th actor trigger verbs" },
	["actor VI"] = { "6th actor trigger", "Tagalog 6th actor trigger verbs" },
	["actor VII"] = { "7th actor trigger", "Tagalog 7th actor trigger verbs" },
	["actor VIII"] = { "8th actor trigger", "Tagalog 8th actor trigger verbs" },
	["actor IX"] = { "9th actor trigger", "Tagalog 9th actor trigger verbs" },
	["object I"] = { "1st object trigger", "Tagalog 1st object trigger verbs" },
	["object II"] = { "2nd object trigger", "Tagalog 2nd object trigger verbs" },
	["object III"] = { "3rd object trigger", "Tagalog 3rd object trigger verbs" },
	["object IV"] = { "4th object trigger", "Tagalog 4th object trigger verbs" },
	["object V"] = { "5th object trigger", "Tagalog 5th object trigger verbs" },
	["object VI"] = { "6th object trigger", "Tagalog 6th object trigger verbs" },
	["locative I"] = { "1st locative trigger", "Tagalog 1st locative trigger verbs" },
	["locative II"] = { "2nd locative trigger", "Tagalog 2nd locative trigger verbs" },
	["locative III"] = { "3rd locative trigger", "Tagalog 3rd locative trigger verbs" },
	["locative IV"] = { "4th locative trigger", "Tagalog 4th locative trigger verbs" },
	["locative V"] = { "5th locative trigger", "Tagalog 5th locative trigger verbs" },
	["benefactive I"] = { "1st benefactive trigger", "Tagalog 1st benefactive trigger verbs" },
	["benefactive II"] = { "2nd benefactive trigger", "Tagalog 2nd benefactive trigger verbs" },
	["benefactive III"] = { "3rd benefactive trigger", "Tagalog 3rd benefactive trigger verbs" },
	["instrument I"] = { "1st instrument trigger", "Tagalog 1st instrument trigger verbs" },
	["instrument II"] = { "2nd instrument trigger", "Tagalog 2nd instrument trigger verbs" },
	["reason"] = { "reason trigger", "Tagalog reason trigger verbs" },
	["directional I"] = { "1st directional trigger", "Tagalog 1st directional trigger verbs" },
	["directional II"] = { "2nd directional trigger", "Tagalog 2nd directional trigger verbs" },
	["reference"] = { "reference trigger", "Tagalog reference trigger verbs" },
	["reciprocal I"] = { "1st reciprocal trigger", "Tagalog 1st reciprocal trigger verbs" },
	["reciprocal II"] = { "2nd reciprocal trigger", "Tagalog 2nd reciprocal trigger verbs" },
}

pos_functions["verbs"] = function(args, data)

    params = {
		[1] = {alias_of = 'head'},
		[2] = {alias_of = 'comp'},
		[3] = {alias_of = 'prog'},
		[4] = {alias_of = 'cont'},
		head = {list = true},
		head2= {},
		head3= {},
		comp = {list = true},
		prog = {list = true},
		cont = {list = true},
		rootword = {},
		type = {},
		b= {},
		b2= {},
		b3= {}
	}

	local args = require("Module:parameters").process(args,params)
	data.heads = args.head
	data.id = args.id
	local pattern = args.pattern
	
	args.comp.label = "complete"
	args.prog.label = "progressive"
	args.cont.label = "contemplative"

	args.comp.accel = {form = "comp"}
	args.prog.accel = {form = "prog"}
	args.cont.accel = {form = "cont"}

	if #args.comp > 0 then table.insert(data.inflections, args.comp) end
	if #args.prog > 0 then table.insert(data.inflections, args.prog) end
	if #args.cont > 0 then table.insert(data.inflections, args.cont) end

    --Tagging root forms of verbs
	local rootword = args["rootword"] or nil
	if require("Module:yesno")(rootword) then 
		table.insert(data.inflections, {label = "root word"}) 
		table.insert(data.categories, "Tagalog roots")
	end

    --Tagging verb trigger
    local conjtype = args["type"] or nil
    if conjtype and conjugation_types[conjtype] then
		table.insert(data.inflections, {label = conjugation_types[conjtype][1]})
		table.insert(data.categories, conjugation_types[conjtype][2])
    end

end

pos_functions["adjectives"] = function(args, data)

	--Tagging plurals of "ma-" type adjectives
	    params = {
		[1] = {alias_of = 'head'},
		head = {list = true},
		head2= {},
		head3= {},
		plural = {list = true},
		b= {},
		b2= {},
		b3= {}
	}
	
	local args = require("Module:parameters").process(args,params)
	data.heads = args.head
	data.id = args.id
	local pattern = args.pattern
	
	args.plural.label = "plural"

	args.plural.accel = {form = "plural"}

	if #args.plural > 0 then table.insert(data.inflections, args.plural) end

end


pos_functions["nouns"] = function(args, data)

	--Tagging root forms of nouns
	local rootword = args["rootword"] or nil 
	if require("Module:yesno")(rootword) then 
		table.insert(data.inflections, {label = "root word"}) 
		table.insert(data.categories, "Tagalog roots")
	end

end

return export