Module:tln-headword: Difference between revisions

From Linguifex
Jump to navigation Jump to search
Nehster9 (talk | contribs)
mNo edit summary
Nehster9 (talk | contribs)
mNo edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
local export = {}
local p = {}
local pos_functions = {}


local lang = require("Module:languages").getByCode("tln")
local function get_args(frame)
    return frame:getParent().args
end


local PAGENAME = mw.title.getCurrentTitle().text
local function format_rom(rom)
    if rom and rom ~= "" then
        return " • (" .. rom .. ")"
    end
    return ""
end


-- Nouns
local function format_gender(g)
pos_functions.nouns = function(class, args, data)
    local gender_map = {
local params = {
        m = "m.",
[1] = {required = true}, -- gender
        f = "f.",
["pl"] = {},
        n = "n."
["head"] = {},
    }
["tr"] = {},
["pltr"] = {},
}


local args = require("Module:parameters").process(args, params)
    local label = gender_map[g] or (g and (g .. ".") or "?.")


local head = args.head or PAGENAME
    return " ''" .. label .. "''"
end


data.lang = lang
-- =========================
data.heads = {head}
-- NOUN
data.genders = {args[1]}
-- =========================
data.inflections = {}
function p.noun(frame)
    local args = get_args(frame)
    local title = mw.title.getCurrentTitle().text


-- plural handling
    local rom = args.rom or ""
if args.pl then
    local g = args.g or "?"
local infl = {
    local pl = args.pl or ""
label = "plural",
    local plrom = args.plrom or ""
{ term = args.pl }
}


if args.pltr then
    local text = "'''" .. title .. "'''"
infl[1].tr = args.pltr
    text = text .. format_rom(rom)
end
    text = text .. format_gender(g)


table.insert(data.inflections, infl)
    if pl ~= "" then
end
        text = text .. " plural '''[[" .. pl .. "]]'''"


if args.tr then
        if plrom ~= "" then
data.translits = {args.tr}
            text = text .. " (" .. plrom .. ")"
end
        end
    end
 
    return text
end
end


-- Entry point
-- =========================
function export.show(frame)
-- VERB
local parent_args = frame:getParent().args
-- =========================
function p.verb(frame)
    local args = frame:getParent().args
    local title = mw.title.getCurrentTitle().text
 
    local rom = args.rom or ""
 
    local pres1 = args.pres1 or ""
    local past1 = args.past1 or ""
    local part = args.part or ""
 
    local pres1rom = args.pres1rom or ""
    local past1rom = args.past1rom or ""
    local partrom = args.partrom or ""
 
    local function format_form(form, rom_form)
        if form == "" then
            return ""
        end
 
        local out = "'''[[" .. form .. "]]'''"
 
        if rom_form and rom_form ~= "" then
            out = out .. " (" .. rom_form .. ")"
        end
 
        return out
    end
 
    local text = "'''" .. title .. "'''"
 
    if rom ~= "" then
        text = text .. " • (" .. rom .. ")"
    end
 
    local parts = {}
 
    if pres1 ~= "" then
        table.insert(parts, "first-person singular present " .. format_form(pres1, pres1rom))
    end
 
    if past1 ~= "" then
        table.insert(parts, "first-person singular past " .. format_form(past1, past1rom))
    end
 
    if part ~= "" then
        table.insert(parts, "past participle " .. format_form(part, partrom))
    end
 
    if #parts > 0 then
        text = text .. " (" .. table.concat(parts, ", ") .. ")"
    end
 
    return text
end


local poscat = frame.args[1] or "nouns"
-- =========================
-- ADJECTIVE (basic placeholder)
-- =========================
function p.adj(frame)
    local args = get_args(frame)
    local title = mw.title.getCurrentTitle().text


local data = {
    local rom = args.rom or ""
inflections = {},
genders = {},
categories = {},
}


if pos_functions[poscat] then
    local text = "'''" .. title .. "'''"
pos_functions[poscat](nil, parent_args, data)
    text = text .. format_rom(rom)
end
    text = text .. " ''adj.''"


return require("Module:headword").full_headword(data)
    return text
end
end


return export
return p

Latest revision as of 01:15, 19 June 2026



local p = {}

local function get_args(frame)
    return frame:getParent().args
end

local function format_rom(rom)
    if rom and rom ~= "" then
        return " • (" .. rom .. ")"
    end
    return ""
end

local function format_gender(g)
    local gender_map = {
        m = "m.",
        f = "f.",
        n = "n."
    }

    local label = gender_map[g] or (g and (g .. ".") or "?.")

    return " ''" .. label .. "''"
end

-- =========================
-- NOUN
-- =========================
function p.noun(frame)
    local args = get_args(frame)
    local title = mw.title.getCurrentTitle().text

    local rom = args.rom or ""
    local g = args.g or "?"
    local pl = args.pl or ""
    local plrom = args.plrom or ""

    local text = "'''" .. title .. "'''"
    text = text .. format_rom(rom)
    text = text .. format_gender(g)

    if pl ~= "" then
        text = text .. " plural '''[[" .. pl .. "]]'''"

        if plrom ~= "" then
            text = text .. " (" .. plrom .. ")"
        end
    end

    return text
end

-- =========================
-- VERB
-- =========================
function p.verb(frame)
    local args = frame:getParent().args
    local title = mw.title.getCurrentTitle().text

    local rom = args.rom or ""

    local pres1 = args.pres1 or ""
    local past1 = args.past1 or ""
    local part = args.part or ""

    local pres1rom = args.pres1rom or ""
    local past1rom = args.past1rom or ""
    local partrom = args.partrom or ""

    local function format_form(form, rom_form)
        if form == "" then
            return ""
        end

        local out = "'''[[" .. form .. "]]'''"

        if rom_form and rom_form ~= "" then
            out = out .. " (" .. rom_form .. ")"
        end

        return out
    end

    local text = "'''" .. title .. "'''"

    if rom ~= "" then
        text = text .. " • (" .. rom .. ")"
    end

    local parts = {}

    if pres1 ~= "" then
        table.insert(parts, "first-person singular present " .. format_form(pres1, pres1rom))
    end

    if past1 ~= "" then
        table.insert(parts, "first-person singular past " .. format_form(past1, past1rom))
    end

    if part ~= "" then
        table.insert(parts, "past participle " .. format_form(part, partrom))
    end

    if #parts > 0 then
        text = text .. " (" .. table.concat(parts, ", ") .. ")"
    end

    return text
end

-- =========================
-- ADJECTIVE (basic placeholder)
-- =========================
function p.adj(frame)
    local args = get_args(frame)
    local title = mw.title.getCurrentTitle().text

    local rom = args.rom or ""

    local text = "'''" .. title .. "'''"
    text = text .. format_rom(rom)
    text = text .. " ''adj.''"

    return text
end

return p