De Muysc cubun - Lengua Muisca
m |
m |
||
| Línea 1: | Línea 1: | ||
local p = {} | local p = {} | ||
| − | -- 1. Limpieza y Normalización | + | -- 1. Limpieza y Normalización |
local function cleanPageName(pageName) | local function cleanPageName(pageName) | ||
pageName = mw.text.trim(pageName or "") | pageName = mw.text.trim(pageName or "") | ||
| Línea 28: | Línea 28: | ||
end | end | ||
| − | -- 2. Función que genera | + | -- 2. Función que genera la tabla con encabezados personalizables |
| − | local function generateTableHtml(title, root, persons, suffixes, applySpecialRule) | + | local function generateTableHtml(title, root, persons, suffixes, applySpecialRule, colNames) |
local html = mw.html.create("table") | local html = mw.html.create("table") | ||
:addClass("wikitable") | :addClass("wikitable") | ||
| Línea 36: | Línea 36: | ||
:css("margin-bottom", "1em") | :css("margin-bottom", "1em") | ||
| − | |||
html:tag("caption"):css("font-weight", "bold"):css("text-align", "left"):wikitext(title) | html:tag("caption"):css("font-weight", "bold"):css("text-align", "left"):wikitext(title) | ||
local header = html:tag("tr") | local header = html:tag("tr") | ||
header:tag("th"):wikitext("Persona") | header:tag("th"):wikitext("Persona") | ||
| − | header:tag("th"):wikitext( | + | header:tag("th"):wikitext(colNames[1]) |
| − | header:tag("th"):wikitext( | + | header:tag("th"):wikitext(colNames[2]) |
| − | header:tag("th"):wikitext( | + | header:tag("th"):wikitext(colNames[3]) |
local firstChar = mw.ustring.lower(mw.ustring.sub(root, 1, 1)) | local firstChar = mw.ustring.lower(mw.ustring.sub(root, 1, 1)) | ||
| Línea 68: | Línea 67: | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local clase = normalizeClass(args.clase or args.tipo or "") | local clase = normalizeClass(args.clase or args.tipo or "") | ||
| − | local | + | local pageName = mw.title.getCurrentTitle().text |
| + | local root = getRoot(pageName, clase, args.raiz or "") | ||
| − | if root == "" or root == | + | if root == "" or root == pageName then |
return "<span style='color:red;'>Error: No se pudo extraer la raíz.</span>" | return "<span style='color:red;'>Error: No se pudo extraer la raíz.</span>" | ||
end | end | ||
| − | -- Definición de | + | -- Definición de Serie 1: Flexión Verbal (Independiente) |
local serie1 = { | local serie1 = { | ||
| + | title = "Serie de Flexión Verbal (Independiente)", | ||
persons = {{"1.ª sg.", "z-"}, {"2.ª sg.", "m-"}, {"3.ª", "a-"}, {"1.ª pl.", "chi-"}, {"2.ª pl.", "mi-"}}, | persons = {{"1.ª sg.", "z-"}, {"2.ª sg.", "m-"}, {"3.ª", "a-"}, {"1.ª pl.", "chi-"}, {"2.ª pl.", "mi-"}}, | ||
suffixes = {perf = "", imperf = (clase == "su." and "-suca" or "-squa"), irreal = "-nga"}, | suffixes = {perf = "", imperf = (clase == "su." and "-suca" or "-squa"), irreal = "-nga"}, | ||
| − | rule = true | + | rule = true, |
| + | cols = {"Perfectivo", "Imperfectivo", "Irrealis"} | ||
} | } | ||
| + | |||
| + | -- Definición de Serie 2: Nominalización (Base de identidad) | ||
local serie2 = { | local serie2 = { | ||
| + | title = "Serie de Nominalización", | ||
persons = {{"1.ª sg.", "cha-"}, {"2.ª sg.", "ma-"}, {"3.ª", ""}, {"1.ª pl.", "chi-"}, {"2.ª pl.", "mi-"}}, | persons = {{"1.ª sg.", "cha-"}, {"2.ª sg.", "ma-"}, {"3.ª", ""}, {"1.ª pl.", "chi-"}, {"2.ª pl.", "mi-"}}, | ||
suffixes = {perf = "-ia", imperf = "-sca", irreal = "-nga"}, | suffixes = {perf = "-ia", imperf = "-sca", irreal = "-nga"}, | ||
| − | rule = false | + | rule = false, |
| + | cols = {"Nominalización Resultativa", "Nominalización Factual", "Nominalización Irrealis"} | ||
} | } | ||
| Línea 96: | Línea 102: | ||
:attr("data-collapsetext", "Ocultar") | :attr("data-collapsetext", "Ocultar") | ||
| − | -- Título del bloque | + | -- Título del bloque (Opcional, se puede añadir texto aquí) |
| − | mainDiv:tag("div") | + | mainDiv:tag("div"):css("margin-bottom", "10px") |
| − | |||
| − | |||
local contentDiv = mainDiv:tag("div") | local contentDiv = mainDiv:tag("div") | ||
:addClass("mw-collapsible-content") | :addClass("mw-collapsible-content") | ||
| − | -- | + | -- Generación de las dos tablas con sus respectivos encabezados |
| − | contentDiv:node(generateTableHtml( | + | contentDiv:node(generateTableHtml(serie1.title, root, serie1.persons, serie1.suffixes, serie1.rule, serie1.cols)) |
| − | contentDiv:node(generateTableHtml( | + | contentDiv:node(generateTableHtml(serie2.title, root, serie2.persons, serie2.suffixes, serie2.rule, serie2.cols)) |
return tostring(mainDiv) | return tostring(mainDiv) | ||
Revisión del 21:06 26 mar 2026
La documentación para este módulo puede ser creada en Módulo:Conjugador/doc
local p = {}
-- 1. Limpieza y Normalización
local function cleanPageName(pageName)
pageName = mw.text.trim(pageName or "")
pageName = mw.ustring.gsub(pageName, "%s*%b()", "")
pageName = mw.ustring.gsub(pageName, "%d+", "")
return mw.text.trim(pageName)
end
local function normalizeClass(rawClass)
rawClass = mw.text.trim(rawClass or "")
rawClass = mw.ustring.lower(rawClass)
if mw.ustring.find(rawClass, "sq") then return "sq."
elseif mw.ustring.find(rawClass, "su") then return "su." end
return ""
end
local function getRoot(pageName, clase, manualRoot)
manualRoot = mw.text.trim(manualRoot or "")
if manualRoot ~= "" then return manualRoot end
local fullVerb = cleanPageName(pageName)
local root = fullVerb
if clase == "sq." then root = mw.ustring.gsub(fullVerb, "squa$", "")
elseif clase == "su." then root = mw.ustring.gsub(fullVerb, "suca$", "") end
if root == fullVerb then root = mw.ustring.gsub(fullVerb, "s[uq]ua$", "") end
return root
end
-- 2. Función que genera la tabla con encabezados personalizables
local function generateTableHtml(title, root, persons, suffixes, applySpecialRule, colNames)
local html = mw.html.create("table")
:addClass("wikitable")
:css("width", "100%")
:css("max-width", "600px")
:css("margin-bottom", "1em")
html:tag("caption"):css("font-weight", "bold"):css("text-align", "left"):wikitext(title)
local header = html:tag("tr")
header:tag("th"):wikitext("Persona")
header:tag("th"):wikitext(colNames[1])
header:tag("th"):wikitext(colNames[2])
header:tag("th"):wikitext(colNames[3])
local firstChar = mw.ustring.lower(mw.ustring.sub(root, 1, 1))
local firstTwo = mw.ustring.lower(mw.ustring.sub(root, 1, 2))
for _, personData in ipairs(persons) do
local label, prefix = personData[1], personData[2]
if applySpecialRule and label == "1.ª sg." then
if firstChar == "n" or firstChar == "z" or firstChar == "t" or firstTwo == "ch" then
prefix = "i-"
end
end
local row = html:tag("tr")
row:tag("td"):css("font-weight", "bold"):wikitext(label)
row:tag("td"):wikitext(prefix .. root .. (suffixes.perf or ""))
row:tag("td"):wikitext(prefix .. root .. (suffixes.imperf or ""))
row:tag("td"):wikitext(prefix .. root .. (suffixes.irreal or ""))
end
return html
end
-- FUNCIÓN PRINCIPAL
function p.render(frame)
local args = frame:getParent().args
local clase = normalizeClass(args.clase or args.tipo or "")
local pageName = mw.title.getCurrentTitle().text
local root = getRoot(pageName, clase, args.raiz or "")
if root == "" or root == pageName then
return "<span style='color:red;'>Error: No se pudo extraer la raíz.</span>"
end
-- Definición de Serie 1: Flexión Verbal (Independiente)
local serie1 = {
title = "Serie de Flexión Verbal (Independiente)",
persons = {{"1.ª sg.", "z-"}, {"2.ª sg.", "m-"}, {"3.ª", "a-"}, {"1.ª pl.", "chi-"}, {"2.ª pl.", "mi-"}},
suffixes = {perf = "", imperf = (clase == "su." and "-suca" or "-squa"), irreal = "-nga"},
rule = true,
cols = {"Perfectivo", "Imperfectivo", "Irrealis"}
}
-- Definición de Serie 2: Nominalización (Base de identidad)
local serie2 = {
title = "Serie de Nominalización",
persons = {{"1.ª sg.", "cha-"}, {"2.ª sg.", "ma-"}, {"3.ª", ""}, {"1.ª pl.", "chi-"}, {"2.ª pl.", "mi-"}},
suffixes = {perf = "-ia", imperf = "-sca", irreal = "-nga"},
rule = false,
cols = {"Nominalización Resultativa", "Nominalización Factual", "Nominalización Irrealis"}
}
--- CONSTRUCCIÓN DEL CONTENEDOR ÚNICO ---
local mainDiv = mw.html.create("div")
:addClass("mw-collapsible")
:addClass("mw-collapsed")
:css("border", "1px solid #a2a9b1")
:css("padding", "10px")
:css("background-color", "#fcfcfc")
:attr("data-expandtext", "Conjugar")
:attr("data-collapsetext", "Ocultar")
-- Título del bloque (Opcional, se puede añadir texto aquí)
mainDiv:tag("div"):css("margin-bottom", "10px")
local contentDiv = mainDiv:tag("div")
:addClass("mw-collapsible-content")
-- Generación de las dos tablas con sus respectivos encabezados
contentDiv:node(generateTableHtml(serie1.title, root, serie1.persons, serie1.suffixes, serie1.rule, serie1.cols))
contentDiv:node(generateTableHtml(serie2.title, root, serie2.persons, serie2.suffixes, serie2.rule, serie2.cols))
return tostring(mainDiv)
end
return p
