Module:ms-headword

Hello, you have come here looking for the meaning of the word Module:ms-headword. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:ms-headword, but we will also tell you about its etymology, its characteristics and you will know how to say Module:ms-headword in singular and plural. Everything you need to know about the word Module:ms-headword you have here. The definition of the word Module:ms-headword will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:ms-headword, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module deploys the Malay headword templates and all associated templates.


local export = {}
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

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

    local data = {
        lang = lang,
        pos_category = poscat,
        categories = {},
        heads = {head},
        translits = {"-"},
        inflections = {}
    }

    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 

table.insert(data.categories, "Malay terms with 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

        table.insert(data.categories, "Malay terms with incorrect Jawi spelling")
        error("Please remove ZWSP, ZWNJ, ZWJ, LRM, and RLM from title/headword.")
    end

    function export.affixation(text, affix)
        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 letter_replacements = { = "m",  = "ng",  = "r"}

    local jawi = {label = "Jawi spelling"}
    local sc_Arab = require("Module:scripts").getByCode("ms-Arab")
    if args then table.insert(jawi, {term = args, sc = sc_Arab}) end
    if args then table.insert(jawi, {term = args, sc = sc_Arab}) end
    if args then table.insert(jawi, {term = args, sc = sc_Arab}) end
    if args then table.insert(jawi, {term = args, sc = sc_Arab}) end
    if #jawi > 0 then table.insert(data.inflections, jawi) end

    local rumi = {label = "Rumi spelling"}
    local sc_Latn = require("Module:scripts").getByCode("Latn")
    if args then table.insert(rumi, {term = args, sc = sc_Latn}) end
    if args then table.insert(rumi, {term = args, sc = sc_Latn}) end
    if args then table.insert(rumi, {term = args, sc = sc_Latn}) end
    if #rumi > 0 then table.insert(data.inflections, rumi) 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
        table.insert(data.categories, "Malay uncountable nouns")
    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

    local ku = {label = "informal 1st possessive"}
    if args ~= "-" or args == nil then
        table.insert(data.inflections, ku)
        if script:getCode() == "ms-Arab" then
            table.insert(ku, mw.ustring.format("%s]", PAGENAME))
        else
            table.insert(ku, mw.ustring.format("%s]", PAGENAME))
        end
    end

    local mu = {label = "2nd possessive"}
    if args ~= "-" or args == nil then
        table.insert(data.inflections, mu)
        if script:getCode() == "ms-Arab" then
            table.insert(mu, mw.ustring.format("%s]", PAGENAME))
        else
            table.insert(mu, mw.ustring.format("%s]", PAGENAME))
        end
    end

    local nya = {label = "3rd possessive"}
    if args ~= "-" or args == nil then
        table.insert(data.inflections, nya)
        if script:getCode() == "ms-Arab" then
            table.insert(nya, mw.ustring.format("%s]", PAGENAME))
        else
            table.insert(nya, mw.ustring.format("%s]", PAGENAME))
        end
    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"})
            table.insert(data.categories, "Malay transitive verbs")
        end
        if tv == "i" or tv == "in" or tv == "intr" or tv == "intransitive" then
            table.insert(data.inflections, {label = "intransitive"})
            table.insert(data.categories, "Malay intransitive verbs")
        end
        if tv == "s" or tv == "st" or tv == "stat" or tv == "stative" then
            table.insert(data.inflections, {label = "stative"})
            table.insert(data.categories, "Malay stative verbs")
        end
    else
        table.insert(data.categories, "Malay verbs without transitivity")
    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