မဝ်ဂျူ:fro-headword

နူ ဝိက်ရှေန်နရဳ

Documentation for this module may be created at မဝ်ဂျူ:fro-headword/doc

local m_fro_utilities = require("Module:fro-utilities")

local export = {}

local lang = require("Module:languages").getByCode("fro")

function export.noun(frame)
    local args = frame:getParent().args
    PAGENAME = mw.title.getCurrentTitle().text
    
    local head = args["head"]; if head == "" then head = nil end
    
    local op = args["op"] or args[2]; if op == "" then op = nil end
    local ns = args["ns"] or args[3]; if ns == "" then ns = nil end
    local np = args["np"] or args[4]; if np == "" then np = nil end
    
    local data = {lang = lang, pos_category = "နာမ်", categories = {}, heads = {head}, genders = {}, inflections = {}}
	
    -- Process the genders
    local valid_genders = {
        ["m"] = true,
        ["f"] = true,
        ["m-p"] = true,
        ["f-p"] = true}
    
    local g = args[1]
    
    if valid_genders[g] then
        data.genders = {g}
        if g == "m" or g == "m-p" then
           
        else
            
        end
    elseif g == "mf" then
        data.genders = {"m", "f"}
       
       
    else
        data.genders = {"?"}
       
    end
    
    -- Generate default plural forms by adding -s.
    -- Note that these are also used for the nominative singular of masculine nouns.
    local plurals = m_fro_utilities.pluralize(PAGENAME)
    
    -- Insert PART, either a string or array, into TAB. If PART is a string,
    -- split on commas.
    local function insert_part(tab, part)
        if type(part) == "table" then
            for _, form in ipairs(part) do
                table.insert(tab, form)
            end
        else
            local forms = mw.text.split(part, ",")
            for _, form in ipairs(forms) do
                table.insert(tab, form)
            end
        end
    end

    -- Oblique plurals are the same for both genders
    local op_parts = {label = "ကိုန်ဨကဝုစ်စေင်ဒၟံင်"}

    insert_part(op_parts, op or plurals)    

    -- Nominative forms differ between the genders
    -- If masculine, the singular gets the -s
    -- If feminine, the plural gets the -s
    local ns_parts = {label = "ကိုန်ဨကဝုစ်ဒုင်ယၟု"}
    local np_parts = {label = "ကိုန်ဗဟုဝစ်ဒုင်ယၟု"}
    
    if data.genders[1] == "m" or data.genders[1] == "m-p" then
        insert_part(np_parts, np or PAGENAME)
        insert_part(ns_parts, ns or plurals)
    else
        insert_part(ns_parts, ns or PAGENAME)
        insert_part(np_parts, np or plurals)
    end
    
    -- Add the inflections
    if op == "-" or data.genders[1] == "m-p" or data.genders[1] == "f-p" then
        table.insert(data.inflections, ns_parts)
        
    else
        table.insert(data.inflections, op_parts)
        table.insert(data.inflections, ns_parts)
        table.insert(data.inflections, np_parts)
    end
    
    return require("Module:headword").full_headword(data)
end
 
return export