Module:id-headword
Appearance
- The following documentation is located at Module:id-headword/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module deploys the Indonesian headword templates and all associated templates.
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 = {}, -- Ensure initialized as an empty table
heads = {head},
translits = {"-"},
inflections = {}
}
if pos_functions[poscat] then
pos_functions[poscat](args, data)
end
return require("Module:headword").full_headword(data)
end
-- Function for nouns (common and proper)
-- Shortcuts for the plural markings
pos_functions["nouns"] = function(args, data)
-- For nouns with unknown or uncertain plural forms or requests for nouns plural forms
if args[1] == "req" then -- Adding [[Category:Request for plural forms in Indonesian entries]]
args["pl"] = "req"
elseif args[1] == "?" then -- Adding [[Category:Indonesian nouns with unknown or uncertain plurals]]
args["pl"] = "?"
-- For uncountable and semi-countable nouns
elseif args[1] == "-" then -- Marking uncountable nouns
args["pl"] = "-"
elseif args[1] == "0" then -- Marking uncountable nouns without the (uncountable) label, if very unnecessary
args["pl"] = "0"
elseif args[1] == "u" then -- Marking usually uncountable nouns
args["pl"] = "u"
elseif args[1] == "~" then -- Marking countable and uncountable nouns both in quality
args["pl"] = "~"
elseif args[1] == "pt" or args[1] == "p" then -- Marking pluralia tantum
args["pl"] = "p"
elseif args[1] == "st" or args[1] == "s" then -- Marking singularia tantum
args["pl"] = "s"
elseif args[1] == "*" then -- Creating unchanged plural forms
args["pl"] = "*"
-- For countable nouns
elseif args[1] == "+" then -- Creating common plural forms (reduplication)
args["pl"] = "+"
elseif args[1] == "a" then -- Creating both common (reduplication) and "para" plural forms for some human nouns
args["pl"] = "a"
end
-- Auto-detect full reduplication
local pagename = mw.title.getCurrentTitle().text -- Get the current page name
if pagename:match("^([a-zA-Z]+)%-%1$") then
local pl = {label = "plural"}
table.insert(pl, mw.ustring.format("[[%s]]", PAGENAME))
if args["pl2"] then table.insert(pl, args["pl2"]) end
if args["pl3"] then table.insert(pl, args["pl3"]) end
table.insert(data.inflections, pl)
return -- Stop further processing
end
-- Initialize categories and inflections if nil (not specified)
data.categories = data.categories or {}
data.inflections = data.inflections or {}
-- Main code for noun plurality
-- Unknown or uncertain and requests
if args["pl"] == "req" then
table.insert(data.categories, "Requests for plural forms in Indonesian entries")
elseif args["pl"] == "?" then
table.insert(data.categories, "Indonesian nouns with unknown or uncertain plurals")
-- Uncountable and semi-countable
elseif args["pl"] == "-" then
table.insert(data.categories, "Indonesian uncountable nouns")
table.insert(data.inflections, {label = "[[Appendix:Glossary#uncountable|uncountable]]"})
elseif args["pl"] == "0" then
table.insert(data.categories, "Indonesian uncountable nouns")
elseif args["pl"] == "u" then
table.insert(data.categories, "Indonesian uncountable nouns")
table.insert(data.inflections, {label = "usually [[Appendix:Glossary#uncountable|uncountable]]"})
elseif args["pl"] == "~" then
local pl_countable = {label = "[[Appendix:Glossary#countable|countable]] and [[Appendix:Glossary#uncountable|uncountable]]"}
local pl_plural = {label = "plural"}
table.insert(data.categories, "Indonesian countable nouns")
table.insert(data.categories, "Indonesian uncountable nouns")
local subwords = mw.text.split(PAGENAME, "%s")
local firstword = subwords[1]
local plural_form = mw.ustring.gsub("[[" .. firstword .. "]]-[[" .. firstword .. "]]", "([a-z]+%-)%1%1", "banyak %1")
table.insert(pl_plural, plural_form)
table.insert(data.inflections, pl_countable)
table.insert(data.inflections, pl_plural)
elseif args["pl"] == "pt" or args["pl"] == "p" then
table.insert(data.categories, "Indonesian pluralia tantum")
table.insert(data.inflections, {label = "[[Appendix:Glossary#plurale tantum|plurale tantum]]"})
elseif args["pl"] == "st" or args["pl"] == "s" then
table.insert(data.categories, "Indonesian singularia tantum")
table.insert(data.inflections, {label = "[[Appendix:Glossary#singulare tantum|singulare tantum]]"})
-- Countable
else
local pl = {label = "plural"}
if not args["pl"] or args["pl"] == "duplication" or args["pl"] == "+" then
local subwords = mw.text.split(PAGENAME, "%s")
local firstword = subwords[1]
subwords[1] = mw.ustring.gsub("[[" .. firstword .. "]]-[[" .. firstword .. "]]", "([a-z]+%-)%1%1", "banyak %1")
if args["pl2"] then table.insert(pl, args["pl2"]) end
if args["pl3"] then table.insert(pl, args["pl3"]) end
table.insert(pl, table.concat(subwords, " "))
elseif args["pl"] == "a" then
local subwords = mw.text.split(PAGENAME, "%s")
local firstword = subwords[1]
local plural_form = firstword .. "-" .. firstword
if #subwords > 1 then
for i = 2, #subwords do
plural_form = plural_form .. " " .. subwords[i]
end
end
table.insert(pl, plural_form)
local para_form = "[[para]] " .. table.concat(subwords, " ")
table.insert(pl, para_form)
if args["pl2"] then table.insert(pl, args["pl2"]) end
if args["pl3"] then table.insert(pl, args["pl3"]) end
elseif args["pl"] == "*" then
table.insert(pl, mw.ustring.format(PAGENAME))
if args["pl2"] then table.insert(pl, args["pl2"]) end
if args["pl3"] then table.insert(pl, args["pl3"]) end
table.insert(data.inflections, pl)
return -- Stop further processing
end
table.insert(data.inflections, pl)
end
-- Function for adjectives
pos_functions["adjectives"] = function(args, data)
end
end
return export