De Muysc cubun - Lengua Muisca
m |
m |
||
| Línea 2: | Línea 2: | ||
-- Limpia el nombre de la página: | -- Limpia el nombre de la página: | ||
| − | -- | + | -- quita espacios y cualquier sufijo tipo (2), (3), etc. |
local function cleanPageName(pageName) | local function cleanPageName(pageName) | ||
pageName = mw.text.trim(pageName or "") | pageName = mw.text.trim(pageName or "") | ||
| − | |||
pageName = mw.ustring.gsub(pageName, "%s*%b()", "") | pageName = mw.ustring.gsub(pageName, "%s*%b()", "") | ||
| − | + | return pageName | |
| − | |||
| − | return | ||
end | end | ||
| − | -- Detecta la clase | + | -- Detecta la clase aunque venga como: |
| + | -- "sq.", "sq", "sq. intr.", "sq. tr.", "su.", "su", etc. | ||
local function normalizeClass(rawClass) | local function normalizeClass(rawClass) | ||
rawClass = mw.text.trim(rawClass or "") | rawClass = mw.text.trim(rawClass or "") | ||
| Línea 22: | Línea 20: | ||
return "su." | return "su." | ||
end | end | ||
| + | |||
| + | return "" | ||
| + | end | ||
| + | |||
| + | -- Detecta transitividad si quieres mostrarla | ||
| + | local function normalizeTrans(rawTrans, rawClass) | ||
| + | rawTrans = mw.text.trim(rawTrans or "") | ||
| + | rawClass = mw.text.trim(rawClass or "") | ||
| + | |||
| + | local combined = mw.ustring.lower(rawTrans .. " " .. rawClass) | ||
| + | |||
| + | if mw.ustring.find(combined, "intr") then | ||
| + | return "intr." | ||
| + | elseif mw.ustring.find(combined, "tr") then | ||
| + | return "tr." | ||
| + | end | ||
| + | |||
return "" | return "" | ||
end | end | ||
| − | -- | + | -- Obtiene la raíz: |
| + | -- 1) si hay |raiz=, la usa | ||
| + | -- 2) si no, quita -squa o -suca del título | ||
local function getRoot(pageName, clase, manualRoot) | local function getRoot(pageName, clase, manualRoot) | ||
manualRoot = mw.text.trim(manualRoot or "") | manualRoot = mw.text.trim(manualRoot or "") | ||
| Línea 32: | Línea 49: | ||
end | end | ||
| − | + | local root = cleanPageName(pageName) | |
| − | local | ||
| − | |||
| − | |||
| − | |||
| − | |||
if clase == "sq." then | if clase == "sq." then | ||
| − | root = mw.ustring.gsub( | + | root = mw.ustring.gsub(root, "squa$", "") |
elseif clase == "su." then | elseif clase == "su." then | ||
| − | root = mw.ustring.gsub( | + | root = mw.ustring.gsub(root, "suca$", "") |
end | end | ||
| − | + | return root | |
| − | + | end | |
| − | |||
| − | |||
| + | local function buildPerfective(root) | ||
return root | return root | ||
end | end | ||
| − | -- .. | + | local function buildImperfective(root, clase) |
| + | if clase == "sq." then | ||
| + | return root .. "-squa" | ||
| + | elseif clase == "su." then | ||
| + | return root .. "-suca" | ||
| + | else | ||
| + | return root .. "-squa" -- fallback | ||
| + | end | ||
| + | end | ||
| + | |||
| + | local function buildIrrealis(root) | ||
| + | return root .. "-nga" | ||
| + | end | ||
function p.render(frame) | function p.render(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
| + | |||
| + | -- Puede venir como clase= sq. o clase= sq. intr. | ||
local rawClass = args.clase or args.tipo or "" | local rawClass = args.clase or args.tipo or "" | ||
| + | local rawTrans = args.trans or "" | ||
local manualRoot = args.raiz or "" | local manualRoot = args.raiz or "" | ||
local clase = normalizeClass(rawClass) | local clase = normalizeClass(rawClass) | ||
| − | + | local trans = normalizeTrans(rawTrans, rawClass) | |
| − | + | ||
| − | local | + | local pageName = mw.title.getCurrentTitle().text |
| − | local root = getRoot( | + | local root = getRoot(pageName, clase, manualRoot) |
if root == "" then | if root == "" then | ||
| Línea 70: | Línea 96: | ||
end | end | ||
| − | -- ( | + | local persons = { |
| − | + | {"1sg", "z-"}, | |
| − | + | {"2sg", "m-"}, | |
| − | + | {"3", "a-"}, | |
| − | + | {"1pl", "chi-"}, | |
| + | {"2pl", "mi-"} | ||
| + | } | ||
| + | |||
| + | local perfectiveBase = buildPerfective(root) | ||
| + | local imperfectiveBase = buildImperfective(root, clase) | ||
| + | local irrealisBase = buildIrrealis(root) | ||
| + | |||
| + | local html = mw.html.create("table") | ||
| + | :addClass("wikitable") | ||
| + | :css("width", "auto") | ||
| + | :css("text-align", "left") | ||
| + | |||
| + | local header = html:tag("tr") | ||
| + | header:tag("th"):wikitext("Persona") | ||
| + | header:tag("th"):wikitext("Perfectivo") | ||
| + | header:tag("th"):wikitext("Imperfectivo") | ||
| + | header:tag("th"):wikitext("Irrealis") | ||
| + | |||
| + | for _, personData in ipairs(persons) do | ||
| + | local label = personData[1] | ||
| + | local prefix = personData[2] | ||
| + | |||
| + | local row = html:tag("tr") | ||
| + | row:tag("td"):wikitext(label) | ||
| + | row:tag("td"):wikitext(prefix .. perfectiveBase) | ||
| + | row:tag("td"):wikitext(prefix .. imperfectiveBase) | ||
| + | row:tag("td"):wikitext(prefix .. irrealisBase) | ||
| + | end | ||
| + | |||
| + | return tostring(html) | ||
end | end | ||
return p | return p | ||
Revisión del 08:35 25 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:
-- quita espacios y cualquier sufijo tipo (2), (3), etc.
local function cleanPageName(pageName)
pageName = mw.text.trim(pageName or "")
pageName = mw.ustring.gsub(pageName, "%s*%b()", "")
return pageName
end
-- Detecta la clase aunque venga como:
-- "sq.", "sq", "sq. intr.", "sq. tr.", "su.", "su", etc.
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
-- Detecta transitividad si quieres mostrarla
local function normalizeTrans(rawTrans, rawClass)
rawTrans = mw.text.trim(rawTrans or "")
rawClass = mw.text.trim(rawClass or "")
local combined = mw.ustring.lower(rawTrans .. " " .. rawClass)
if mw.ustring.find(combined, "intr") then
return "intr."
elseif mw.ustring.find(combined, "tr") then
return "tr."
end
return ""
end
-- Obtiene la raíz:
-- 1) si hay |raiz=, la usa
-- 2) si no, quita -squa o -suca del título
local function getRoot(pageName, clase, manualRoot)
manualRoot = mw.text.trim(manualRoot or "")
if manualRoot ~= "" then
return manualRoot
end
local root = cleanPageName(pageName)
if clase == "sq." then
root = mw.ustring.gsub(root, "squa$", "")
elseif clase == "su." then
root = mw.ustring.gsub(root, "suca$", "")
end
return root
end
local function buildPerfective(root)
return root
end
local function buildImperfective(root, clase)
if clase == "sq." then
return root .. "-squa"
elseif clase == "su." then
return root .. "-suca"
else
return root .. "-squa" -- fallback
end
end
local function buildIrrealis(root)
return root .. "-nga"
end
function p.render(frame)
local args = frame:getParent().args
-- Puede venir como clase= sq. o clase= sq. intr.
local rawClass = args.clase or args.tipo or ""
local rawTrans = args.trans or ""
local manualRoot = args.raiz or ""
local clase = normalizeClass(rawClass)
local trans = normalizeTrans(rawTrans, rawClass)
local pageName = mw.title.getCurrentTitle().text
local root = getRoot(pageName, clase, manualRoot)
if root == "" then
return "<span style='color:red;'>Error: no se pudo identificar la raíz.</span>"
end
local persons = {
{"1sg", "z-"},
{"2sg", "m-"},
{"3", "a-"},
{"1pl", "chi-"},
{"2pl", "mi-"}
}
local perfectiveBase = buildPerfective(root)
local imperfectiveBase = buildImperfective(root, clase)
local irrealisBase = buildIrrealis(root)
local html = mw.html.create("table")
:addClass("wikitable")
:css("width", "auto")
:css("text-align", "left")
local header = html:tag("tr")
header:tag("th"):wikitext("Persona")
header:tag("th"):wikitext("Perfectivo")
header:tag("th"):wikitext("Imperfectivo")
header:tag("th"):wikitext("Irrealis")
for _, personData in ipairs(persons) do
local label = personData[1]
local prefix = personData[2]
local row = html:tag("tr")
row:tag("td"):wikitext(label)
row:tag("td"):wikitext(prefix .. perfectiveBase)
row:tag("td"):wikitext(prefix .. imperfectiveBase)
row:tag("td"):wikitext(prefix .. irrealisBase)
end
return tostring(html)
end
return p
