local pos_functions = {}
local u = require("Module:string/char")
local lang = require("Module:languages").getByCode("ms")
local PAGENAME = mw.loadData("Module:headword/data").pagename
local script = lang:findBestScript(PAGENAME) -- Latn or ms-Arab
local trackfn = require("Module:debug").track
local function track(page)
trackfn("ms-headword/" .. page)
return true
end
function export.show(frame)
-- FIXME: use ].
local args = frame:getParent().args
local poscat = frame.args or error(
"Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local head = args; if head == "" then head = nil end
if (mw.ustring.find(PAGENAME, "اء")) then
head = mw.ustring
.gsub(PAGENAME, "(ا)(ء)()", "%1<sup>%2</sup>%3") -- superscript hamza
end
if args ~= nil or args ~= nil or args ~= nil then
track("clean up kumunya")
end
if args ~= nil then
track("clean up r")
end
local data = {
lang = lang,
pos_category = poscat,
categories = {},
heads = { head },
translits = { "-" },
inflections = {},
altform = script:getCode() == "ms-Arab"
}
if (head and mw.ustring.find(head, "")) or
(args and mw.ustring.find(args, "")) or
(args and mw.ustring.find(args, "")) or
(args and mw.ustring.find(args, "")) or
(args and mw.ustring.find(args, "")) then
track("incorrect Jawi spelling")
error("Please use ک in place of ك and ݢ in place of ڬ.")
end
local special_marks = "" -- ZWSP, ZWNJ, ZWJ, LRM, RLM
if (head and mw.ustring.find(head, special_marks)) or
(args and mw.ustring.find(args, special_marks)) or
(args and mw.ustring.find(args, special_marks)) or
(args and mw.ustring.find(args, special_marks)) or
(args and mw.ustring.find(args, special_marks)) then
track("incorrect Jawi spelling")
error("Please remove ZWSP, ZWNJ, ZWJ, LRM, and RLM from title/headword.")
end
local letter_replacements = { = "m", = "ng", = "r" }
local pattern_replacements = { }
function export.affixation(text, affix)
local first_consonant = ""
if affix == "-" then
text = text .. "-" .. text
elseif mw.ustring.match(affix, "^%-.+%-$") then
first_consonant = mw.ustring.match(text, "^+")
text = first_consonant .. mw.ustring.sub(affix, 2, -2) ..
mw.ustring.sub(text, mw.ustring.len(first_consonant) + 1,
-1)
else
text = gsub(affix, "%-", "#" .. text)
text = gsub(text, "N(*)()(*)$", "nge%1%2%3")
text = gsub(text, "meN#p", "memp")
for pattern, replacement in pairs(pattern_replacements) do
text = gsub(text, pattern, replacement)
end
text = gsub(text, "#?", letter_replacements)
text = gsub(text, "#", "")
end
return text
end
local jawi = { label = "Jawi spelling" }
if args then table.insert(jawi, { term = args }) end
if args then table.insert(jawi, { term = args }) end
if args then table.insert(jawi, { term = args }) end
if args then table.insert(jawi, { term = args }) end
if #jawi > 0 then table.insert(data.inflections, jawi) end
if script:getCode() == "ms-Arab" then
table.insert(data.categories, "Malay terms in Arabic script")
end
if pos_functions then pos_functions(args, data) end
return require("Module:headword").full_headword(data)
end
pos_functions = function(args, data)
local pl = { label = "plural" }
if args == "-" then
if script:getCode() ~= "ms-Arab" then table.insert(data.categories, "Malay uncountable nouns") end
else
if args == nil then
-- common plural
local subwords = mw.text.split(PAGENAME, "%s")
local firstword = subwords
subwords = mw.ustring.gsub(
"]-]",
"(+%-)%1%1", "%1") -- reduplicate only first word
table.insert(pl, table.concat(subwords, " "))
if script:getCode() == "ms-Arab" then
-- reduplicated form in Jawi
subwords = mw.ustring.gsub(
"]]",
"(+%-)%1%1", "%1") -- add "2" only first word
table.insert(pl, table.concat(subwords, " "))
end
else
table.insert(pl, args)
if args then table.insert(pl, args) end
if args then table.insert(pl, args) end
end
table.insert(data.inflections, pl)
end
end
pos_functions = function(args, data)
local pl = { label = "plural" }
-- not necessary to have plural(s)
if args then table.insert(pl, args) end
if args then table.insert(pl, args) end
if args then table.insert(pl, args) end
if #pl > 0 then table.insert(data.inflections, pl) end
end
local aliases = {
= 'trp',
= 'trp',
= 'tro',
= 'tro',
= 'in',
= 'in',
= 'in',
= 'fl',
= 'fl'
}
pos_functions = function(args, data)
local tv = args or ""
tv = aliases or tv
if tv ~= "" then
if tv == "t" or tv == "tr" or tv == "tran" or tv == "transitive" then
table.insert(data.inflections, { label = "transitive" })
if script:getCode() ~= "ms-Arab" then table.insert(data.categories, "Malay transitive verbs") end
end
if tv == "i" or tv == "in" or tv == "intr" or tv == "intransitive" then
table.insert(data.inflections, { label = "intransitive" })
if script:getCode() ~= "ms-Arab" then table.insert(data.categories, "Malay intransitive verbs") end
end
if tv == "s" or tv == "st" or tv == "stat" or tv == "stative" then
table.insert(data.inflections, { label = "stative" })
if script:getCode() ~= "ms-Arab" then table.insert(data.categories, "Malay stative verbs") end
end
end
end
pos_functions = function(args, data)
local aform = { label = "used in the form" }
for _, a in ipairs(args) do table.insert(aform, a) end
if #aform > 0 then
table.insert(data.inflections, aform)
end
end
pos_functions = function(args, data)
local se = { label = "singular" }
if args ~= "-" or args == nil then
table.insert(data.inflections, se)
if script:getCode() == "ms-Arab" then
table.insert(se, mw.ustring.format("]", PAGENAME))
else
table.insert(se, mw.ustring.format("]", PAGENAME))
end
end
end
return export