Module:Fro-headword

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 = "nouns", 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
            table.insert(data.categories, "Auld French masculine nouns")
        else
            table.insert(data.categories, "Auld French feminine nouns")
        end
    elseif g == "mf" then
        data.genders = {"m", "f"}
        table.insert(data.categories, "Auld French masculine nouns")
        table.insert(data.categories, "Auld French feminine nouns")
    else
        data.genders = {"?"}
        table.insert(data.categories, "Auld French terms wi incomplete gender")
    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 = "oblique plural"}

    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 = "nominative singular"}
    local np_parts = {label = "nominative plural"}
    
    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)
        table.insert(data.categories, "Old French uncountable nouns")
    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

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.