De Muysc cubun - Lengua Muisca
m |
m |
||
| Línea 1: | Línea 1: | ||
local p = {} | local p = {} | ||
| + | |||
| + | -- Limpia el nombre de la página: | ||
| + | -- 1) quita espacios sobrantes | ||
| + | -- 2) quita sufijos tipo "(2)", "(3)", etc. | ||
| + | local function cleanPageName(pageName) | ||
| + | pageName = mw.text.trim(pageName or "") | ||
| + | pageName = mw.ustring.gsub(pageName, "%s*%b()", "") -- quita (2), (3), etc. | ||
| + | return pageName | ||
| + | end | ||
| + | |||
| + | -- Obtiene la raíz según el tipo verbal | ||
| + | local function getRoot(pageName, clase) | ||
| + | local root = cleanPageName(pageName) | ||
| + | |||
| + | clase = mw.text.trim(clase or "") | ||
| + | |||
| + | if clase == "sq." then | ||
| + | -- quita "squa" al final | ||
| + | root = mw.ustring.gsub(root, "squa$", "") | ||
| + | elseif clase == "su." then | ||
| + | -- quita "suca" al final | ||
| + | root = mw.ustring.gsub(root, "suca$", "") | ||
| + | end | ||
| + | |||
| + | return root | ||
| + | end | ||
function p.render(frame) | function p.render(frame) | ||
| + | local args = frame:getParent().args | ||
| + | |||
| + | -- clase = sq. o su. | ||
| + | local clase = mw.text.trim(args.clase or "") | ||
| + | |||
| + | -- transitividad opcional (intr. / tr.), por si luego quieres mostrarla | ||
| + | local trans = mw.text.trim(args.trans or "") | ||
| + | |||
local pageName = mw.title.getCurrentTitle().text | local pageName = mw.title.getCurrentTitle().text | ||
| − | local | + | local root = getRoot(pageName, clase) |
| + | |||
| + | -- Si no hay raíz válida, no mostrar nada | ||
| + | if root == "" then | ||
| + | return "<span style='color:red;'>Error: no se pudo identificar la raíz.</span>" | ||
| + | end | ||
| + | |||
| + | local forms = { | ||
| + | ["1sg"] = "z-" .. root, | ||
| + | ["2sg"] = "m-" .. root, | ||
| + | ["3"] = "a-" .. root, | ||
| + | ["1pl"] = "chi-" .. root, | ||
| + | ["2pl"] = "mi-" .. root | ||
| + | } | ||
| + | |||
| + | local html = mw.html.create("table") | ||
| + | :addClass("wikitable") | ||
| + | :css("width", "auto") | ||
| + | :css("text-align", "left") | ||
| + | |||
| + | -- Cabecera | ||
| + | local header = html:tag("tr") | ||
| + | header:tag("th"):wikitext("Persona") | ||
| + | header:tag("th"):wikitext("Forma") | ||
| + | |||
| + | -- Filas | ||
| + | local order = {"1sg", "2sg", "3", "1pl", "2pl"} | ||
| − | for | + | for _, person in ipairs(order) do |
| − | + | local row = html:tag("tr") | |
| + | row:tag("td"):wikitext(person) | ||
| + | row:tag("td"):wikitext(forms[person]) | ||
end | end | ||
| − | + | -- Puedes añadir info arriba si quieres | |
| + | local output = "" | ||
| + | |||
| + | if clase ~= "" or trans ~= "" then | ||
| + | output = output .. string.format( | ||
| + | "<div><b>Clase:</b> %s %s</div>", | ||
| + | clase, | ||
| + | trans | ||
| + | ) | ||
| + | end | ||
| + | |||
| + | output = output .. string.format( | ||
| + | "<div><b>Raíz detectada:</b> %s</div>", | ||
| + | root | ||
| + | ) | ||
| + | |||
| + | output = output .. tostring(html) | ||
| + | |||
| + | return output | ||
end | end | ||
return p | return p | ||
Revisión del 20:10 24 mar 2026
La documentación para este módulo puede ser creada en Módulo:Conjugador/doc
local p = {}
-- Limpia el nombre de la página:
-- 1) quita espacios sobrantes
-- 2) quita sufijos tipo "(2)", "(3)", etc.
local function cleanPageName(pageName)
pageName = mw.text.trim(pageName or "")
pageName = mw.ustring.gsub(pageName, "%s*%b()", "") -- quita (2), (3), etc.
return pageName
end
-- Obtiene la raíz según el tipo verbal
local function getRoot(pageName, clase)
local root = cleanPageName(pageName)
clase = mw.text.trim(clase or "")
if clase == "sq." then
-- quita "squa" al final
root = mw.ustring.gsub(root, "squa$", "")
elseif clase == "su." then
-- quita "suca" al final
root = mw.ustring.gsub(root, "suca$", "")
end
return root
end
function p.render(frame)
local args = frame:getParent().args
-- clase = sq. o su.
local clase = mw.text.trim(args.clase or "")
-- transitividad opcional (intr. / tr.), por si luego quieres mostrarla
local trans = mw.text.trim(args.trans or "")
local pageName = mw.title.getCurrentTitle().text
local root = getRoot(pageName, clase)
-- Si no hay raíz válida, no mostrar nada
if root == "" then
return "<span style='color:red;'>Error: no se pudo identificar la raíz.</span>"
end
local forms = {
["1sg"] = "z-" .. root,
["2sg"] = "m-" .. root,
["3"] = "a-" .. root,
["1pl"] = "chi-" .. root,
["2pl"] = "mi-" .. root
}
local html = mw.html.create("table")
:addClass("wikitable")
:css("width", "auto")
:css("text-align", "left")
-- Cabecera
local header = html:tag("tr")
header:tag("th"):wikitext("Persona")
header:tag("th"):wikitext("Forma")
-- Filas
local order = {"1sg", "2sg", "3", "1pl", "2pl"}
for _, person in ipairs(order) do
local row = html:tag("tr")
row:tag("td"):wikitext(person)
row:tag("td"):wikitext(forms[person])
end
-- Puedes añadir info arriba si quieres
local output = ""
if clase ~= "" or trans ~= "" then
output = output .. string.format(
"<div><b>Clase:</b> %s %s</div>",
clase,
trans
)
end
output = output .. string.format(
"<div><b>Raíz detectada:</b> %s</div>",
root
)
output = output .. tostring(html)
return output
end
return p
