Módulo:pron-graf
La documentación para este módulo puede ser creada en Módulo:pron-graf/doc
local export = {}
local argumentos_simples = {"d", "ac", "ls", "nl", "ts", "tl", "e", "g", "v", "h", "p", "s", "rima"}
local argumentos_nombres = {"silabación", "acentuación", "longitud silábica", "número de letras", "transcripciones silábicas", "transliteraciones", "escrituras alternativas", "grafías alternativas", "variantes", "homófonos", "parónimos", "símbolos", "rimas"}
local argumentos_links = {false, false, false, false, false, false, true, true, true, true, true, true, false}
local booleano = require("Módulo:sí-no")
local obtener_idioma = require("Módulo:lenguas").cod_a_idioma
local sortkey = require("Módulo:sortkey").generarSortkey
local pron_auto = {
["es"] = true,
["alc"] = true,
["ang"] = true,
["arn"] = true,
["ast"] = true,
["az"] = true,
["azd"] = true,
["azn"] = true,
["azz"] = true,
["ca"] = true,
["cub"] = true,
["eo"] = true,
["fi"] = true,
["fr"] = true,
["gn"] = true,
["grc"] = true,
["hy"] = true,
["it"] = true,
["la"] = true,
["naz"] = true,
["nch"] = true,
["nci"] = true,
["ncj"] = true,
["ncl"] = true,
["ncx"] = true,
["ngu"] = true,
["nhc"] = true,
["nhe"] = true,
["nhg"] = true,
["nhi"] = true,
["nhk"] = true,
["nhm"] = true,
["nhn"] = true,
["nht"] = true,
["nhv"] = true,
["nhw"] = true,
["nhx"] = true,
["nhy"] = true,
["nlv"] = true,
["nsu"] = true,
["nuz"] = true,
["pl"] = true,
["pt"] = true,
["ru"] = true,
["sh"] = true,
["sk"] = true,
["tok"] = true,
["uk"] = true,
}
function export.mostrar(frame)
local params = {
[1] = {alias_de = "fone"},
["leng"] = {por_defecto = "es", requerido = true},
["alt"] = {},
["ayuda"] = {lista = true},
["ayudaextra"] = {lista = true},
["pron"] = {lista_doble = true},
["fone"] = {lista_doble = true},
["fono"] = {lista_doble = true},
["fgraf"] = {lista_doble = true},
["fnota"] = {lista_doble = true},
["audio"] = {lista_doble = true},
["aunota"] = {lista_doble = true},
["ac"] = {},
["acentuación"] = {alias_de = "ac"},
["ls"] = {tipo = "num"},
["longitud_silábica"] = {alias_de = "ls"},
["nl"] = {tipo = "num"},
["número_letras"] = {alias_de = "nl"},
["d"] = {lista = true},
["div"] = {alias_de = "d"},
["división"] = {alias_de = "d"},
["dnota"] = {lista = true},
["ts"] = {lista = true},
["transcripción silábica"] = {alias_de = "ts"},
["tsnota"] = {lista = true},
["tl"] = {lista = true},
["transliteración"] = {alias_de = "tl"},
["tlalt"] = {lista = true},
["tlnum"] = {lista = true},
["tlnúm"] = {alias_de = "tlnum"},
["tlnota"] = {lista = true},
["e"] = {lista = true},
["ea"] = {alias_de = "e"},
["escritura alternativa"] = {alias_de = "e"},
["ealt"] = {lista = true},
["enum"] = {lista = true},
["enúm"] = {alias_de = "enum"},
["enota"] = {lista = true},
["g"] = {lista = true},
["ga"] = {alias_de = "g"},
["grafía alternativa"] = {alias_de = "g"},
["galt"] = {lista = true},
["gnum"] = {lista = true},
["gnúm"] = {alias_de = "gnum"},
["gnota"] = {lista = true},
["v"] = {lista = true},
["variante"] = {alias_de = "v"},
["valt"] = {lista = true},
["vnum"] = {lista = true},
["vnúm"] = {alias_de = "vnum"},
["vtr"] = {lista = true},
["vnota"] = {lista = true},
["h"] = {lista = true},
["homófono"] = {alias_de = "h"},
["halt"] = {lista = true},
["hnum"] = {lista = true},
["hnúm"] = {alias_de = "hnum"},
["htr"] = {lista = true},
["hnota"] = {lista = true},
["p"] = {lista = true},
["parónimo"] = {alias_de = "p"},
["palt"] = {lista = true},
["pnum"] = {lista = true},
["pnúm"] = {alias_de = "pnum"},
["ptr"] = {lista = true},
["pnota"] = {lista = true},
["s"] = {lista = true},
["símbolo"] = {alias_de = "s"},
["salt"] = {lista = true},
["snum"] = {lista = true},
["snúm"] = {alias_de = "snum"},
["snota"] = {lista = true},
["rima"] = {},
}
local parent_frame = frame:getParent()
local args = require("Módulo:parámetros").obtener_parametros(parent_frame.args, params)
local title_ = mw.title.getCurrentTitle()
local title = title_.fullText -- no sirve parent_frame:getTitle()
local ns = title_.namespace
local LENG = args["leng"]:upper()
local leng = args["leng"]
local idioma, sk
if ns == 0 then
idioma = obtener_idioma(leng)
sk = sortkey(title, leng, idioma)
end
--local frame = mw.getCurrentFrame()
if args["pron"][1] and booleano(args["pron"][1][1], true) == false then
return nil
end
local table_markup = {}
table.insert(table_markup, '{|class="pron-graf toccolours" style="float: right;"\n|style="background:#DBDBDB;" colspan="2"|<span style="font-family: Arial, sans-serif; font-size: 1.5em;">'..(args["alt"] and args["alt"] or title)..'</span>\n')
if pron_auto[leng] then
args = require("Módulo:generar-pron/"..leng).procesar_pron_args(title, args)
end
local N = math.max(#args["fone"], #args["fono"])
if N == 0 then
table.insert(table_markup, "|-\n|'''pronunciación'''" .. '\n|<span style="color: green; font-size: 90%; font-style: italic;"> falta [[Wikcionario:Pronunciación|agregar]]</span>[[Categoría:'..LENG..':Palabras sin transcripción fonética]]\n')
else
for i = 1,N do
if args["fone"][i] or args["fono"][i] then
table.insert(table_markup, '|-\n')
if args["pron"][i] and args["pron"][i][1] then
table.insert(table_markup, '|'..'[[Wikcionario:Referencia/'..LENG.."/Pronunciación|'''"..args["pron"][i][1].."''']]"..' ([[Alfabeto Fonético Internacional|AFI]])'..'\n|')
else
table.insert(table_markup, '|'..'[[Wikcionario:Referencia/'..LENG.."/Pronunciación|'''pronunciación''']]"..' ([[Alfabeto Fonético Internacional|AFI]])'..'\n|')
end
for j = 1,9 do
local br = false
local fone_espacio = false
local graf_espacio = false
if args["fgraf"][i] and args["fgraf"][i][j] then
table.insert(table_markup, "'''"..args["fgraf"][i][j].."''' ")
graf_espacio = true
end
if args["fone"][i] and args["fone"][i][j] then
table.insert(table_markup, graf_espacio and ' ['..args["fone"][i][j]..']' or '['..args["fone"][i][j]..']')
fone_espacio = true
br = true
end
if args["fono"][i] and args["fono"][i][j] then
table.insert(table_markup, fone_espacio and ' /'..args["fono"][i][j]..'/' or '/'..args["fono"][i][j]..'/')
br = true
end
if args["fnota"][i] and args["fnota"][i][j] then
table.insert(table_markup, ' ('..args["fnota"][i][j]..')')
br = true
end
if args["audio"][i] and args["audio"][i][j] then
if args["aunota"][i] and args["aunota"][i][j] then
table.insert(table_markup, " "..frame:extensionTag("phonos", frame:extensionTag("small", "''"..args["aunota"][i][j].."''"), {class = "pron-graf", file = args["audio"][i][j], leng = args["leng"]}))
else
table.insert(table_markup, " "..frame:extensionTag("phonos", nil, {file = args["audio"][i][j], leng = args["leng"]}))
end
br = true
end
if br then
table.insert(table_markup, '<br/>') --salto de línea sin cambiar de fila
end
end
table.insert(table_markup, '\n')
end
end
end
for i,arg in ipairs(argumentos_simples) do
local argum = args[arg]
local argnombre = argumentos_nombres[i]
local argalt = args[arg.."alt"] or {}
local argtr = args[arg.."tr"] or {}
local argnum = args[arg.."num"] or {}
local argnota = args[arg.."nota"] or {}
if arg == "rima" and argum and idioma then
table.insert(table_markup, "|-\n|'''rima'''\n|[[:Categoría:"..LENG..":Rimas:"..args["rima"].."|"..args["rima"].."]]".."[[Categoría:"..LENG..":Rimas:"..args["rima"].."]]\n")
elseif arg == "ac" and argum then
local acentuacion_tabla = {
['m'] = 'monosílaba',
['a'] = 'aguda',
['l'] = 'llana',
['g'] = 'llana',
['e'] = 'esdrújula',
['s'] = 'sobreesdrújula',
['d'] = 'doble',
}
local acento = argum == "mente" and "doble" or acentuacion_tabla[argum:sub(1,1)]
local acento_cat = acento == "doble" and "con 2 sílabas tónicas" or acento.."s"
if acento and sk then
table.insert(table_markup, "|-\n|'''acentuación'''\n|"..acento..'[[Categoría:'..LENG..':Palabras '..acento_cat.."|"..sk..']]\n')
end
elseif arg == "ls" and argum then
local l_silabica_tabla = {
[1] = 'monosílaba',
[2] = 'bisílaba',
[3] = 'trisílaba',
[4] = 'tetrasílaba',
[5] = 'pentasílaba',
[6] = 'hexasílaba',
[7] = 'heptasílaba',
[8] = 'octosílaba',
[9] = 'eneasílaba',
[10] = 'decasílaba',
[11] = 'endecasílaba',
[12] = 'dodecasílaba',
}
local l_silabica = l_silabica_tabla[argum] or argum
if sk then
if type(l_silabica) == 'number' then
table.insert(table_markup, "|-\n|'''longitud silábica'''\n|"..tostring(l_silabica)..'[[Categoría:'..LENG..':Palabras con más de doce sílabas'.."|"..sk..']]\n')
else
table.insert(table_markup, "|-\n|'''longitud silábica'''\n|"..l_silabica..'[[Categoría:'..LENG..':Palabras '..l_silabica..'s'..'|'..sk..']]\n')
end
end
elseif type(argum) == "string" then
table.insert(table_markup, "|-\n|'''"..argnombre.."'''\n|"..argum..'\n')
elseif type(argum) == "table" and #argum > 0 then
table.insert(table_markup, "|-\n|'''"..argnombre.."'''\n|")
for j,_ in ipairs(argum) do
local argval = argumentos_links[i] and ("[["..argum[j]..(argalt[j] and "|"..argalt[j] or "").."]]") or argum[j]
table.insert(table_markup, (j>1 and ", " or "")..argval..(argtr[j] and " ("..argtr[j]..")" or "")..(argnum[j] and " ("..argnum[j]..")" or "")..(argnota[j] and frame:extensionTag("ref", argnota[j]) or ""))
end
table.insert(table_markup, '\n')
end
end
table.insert(table_markup, '|}')
table.insert(table_markup, require("Módulo:TemplateStyles")("Plantilla:pron-graf/styles.css"))
return table.concat(table_markup)
end
function export.mostrar_(frame)
local params = {
[1] = {alias_de = "fone"},
["leng"] = {por_defecto = "es", requerido = true},
["alt"] = {},
["ayuda"] = {lista = true},
["ayudaextra"] = {lista = true},
["pron"] = {lista_doble = true},
["fone"] = {lista_doble = true},
["fono"] = {lista_doble = true},
["fgraf"] = {lista_doble = true},
["fnota"] = {lista_doble = true},
["audio"] = {lista_doble = true},
["aunota"] = {lista_doble = true},
["ac"] = {},
["acentuación"] = {alias_de = "ac"},
["ls"] = {tipo = "num"},
["longitud_silábica"] = {alias_de = "ls"},
["nl"] = {tipo = "num"},
["número_letras"] = {alias_de = "nl"},
["d"] = {lista = true},
["div"] = {alias_de = "d"},
["división"] = {alias_de = "d"},
["dnota"] = {lista = true},
["ts"] = {lista = true},
["transcripción silábica"] = {alias_de = "ts"},
["tsnota"] = {lista = true},
["tl"] = {lista = true},
["transliteración"] = {alias_de = "tl"},
["tlalt"] = {lista = true},
["tlnum"] = {lista = true},
["tlnúm"] = {alias_de = "tlnum"},
["tlnota"] = {lista = true},
["e"] = {lista = true},
["ea"] = {alias_de = "e"},
["escritura alternativa"] = {alias_de = "e"},
["ealt"] = {lista = true},
["enum"] = {lista = true},
["enúm"] = {alias_de = "enum"},
["enota"] = {lista = true},
["g"] = {lista = true},
["ga"] = {alias_de = "g"},
["grafía alternativa"] = {alias_de = "g"},
["galt"] = {lista = true},
["gnum"] = {lista = true},
["gnúm"] = {alias_de = "gnum"},
["gnota"] = {lista = true},
["v"] = {lista = true},
["variante"] = {alias_de = "v"},
["valt"] = {lista = true},
["vnum"] = {lista = true},
["vnúm"] = {alias_de = "vnum"},
["vtr"] = {lista = true},
["vnota"] = {lista = true},
["h"] = {lista = true},
["homófono"] = {alias_de = "h"},
["halt"] = {lista = true},
["hnum"] = {lista = true},
["hnúm"] = {alias_de = "hnum"},
["htr"] = {lista = true},
["hnota"] = {lista = true},
["p"] = {lista = true},
["parónimo"] = {alias_de = "p"},
["palt"] = {lista = true},
["pnum"] = {lista = true},
["pnúm"] = {alias_de = "pnum"},
["ptr"] = {lista = true},
["pnota"] = {lista = true},
["s"] = {lista = true},
["símbolo"] = {alias_de = "s"},
["salt"] = {lista = true},
["snum"] = {lista = true},
["snúm"] = {alias_de = "snum"},
["snota"] = {lista = true},
["rima"] = {},
}
local parent_frame = frame:getParent()
local args = require("Módulo:parámetros").obtener_parametros(parent_frame.args, params)
local title_ = mw.title.getCurrentTitle()
local title = title_.fullText -- no sirve parent_frame:getTitle()
local ns = title_.namespace
local LENG = args["leng"]:upper()
local leng = args["leng"]
local idioma, sk
if ns == 0 then
idioma = obtener_idioma(leng)
sk = sortkey(title, leng, idioma)
end
--local frame = mw.getCurrentFrame()
if args["pron"][1] and booleano(args["pron"][1][1], true) == false then
return nil
end
local items = {"=== Pronunciación y escritura ===\n"}
if pron_auto[leng] then
args = require("Módulo:generar-pron/"..leng).procesar_pron_args(title, args)
end
local N = math.max(#args["fone"], #args["fono"])
if N == 0 then
table.insert(items, '<span style="color: green; font-size: 90%; font-style: italic;"> Si puede, agréguela mediante {{pron-graf}}</span>[[Categoría:'..LENG..':Palabras sin transcripción fonética]]\n')
else
local tabla = {"{|style='border-spacing: 5px;'"}
for i = 1,N do
if args["fone"][i] or args["fono"][i] then
table.insert(tabla, '\n|-\n|')
if args["pron"][i] and args["pron"][i][1] then
table.insert(tabla, '[[Wikcionario:Referencia/'..LENG.."/Pronunciación|"..args["pron"][i][1].."]]"..' ([[Alfabeto Fonético Internacional|AFI]])'..': ')
else
table.insert(tabla, '[[Wikcionario:Referencia/'..LENG.."/Pronunciación|Pronunciación]]"..' ([[Alfabeto Fonético Internacional|AFI]])'..': ')
end
for j = 1,9 do
if (args["fone"][i] and args["fone"][i][j]) or (args["fono"][i] and args["fono"][i][j]) then
if j > 1 then
table.insert(tabla, '\n|-\n|')
end
local fone_espacio = false
local graf_espacio = false
table.insert(tabla, "\n|")
if args["fgraf"][i] and args["fgraf"][i][j] then
table.insert(tabla, "'''"..args["fgraf"][i][j].."''' ")
graf_espacio = true
end
table.insert(tabla, "\n|")
if args["fone"][i] and args["fone"][i][j] then
table.insert(tabla, graf_espacio and ' ['..args["fone"][i][j]..']' or '['..args["fone"][i][j]..']')
fone_espacio = true
end
if args["fono"][i] and args["fono"][i][j] then
table.insert(tabla, fone_espacio and ' /'..args["fono"][i][j]..'/' or '/'..args["fono"][i][j]..'/')
end
table.insert(tabla, "\n|")
if args["fnota"][i] and args["fnota"][i][j] then
table.insert(tabla, ' ('..args["fnota"][i][j]..')')
end
table.insert(tabla, "\n|")
if args["audio"][i] and args["audio"][i][j] then
if args["aunota"][i] and args["aunota"][i][j] then
table.insert(tabla, " "..frame:extensionTag("phonos", frame:extensionTag("small", "''"..args["aunota"][i][j].."''"), {class = "pron-graf", file = args["audio"][i][j], leng = args["leng"]}))
else
table.insert(tabla, " "..frame:extensionTag("phonos", nil, {file = args["audio"][i][j], leng = args["leng"]}))
end
end
end
end
end
end
if #tabla > 1 then
table.insert(items, table.concat(tabla).."\n|}\n")
end
end
for i,arg in ipairs(argumentos_simples) do
local argum = args[arg]
local argnombre = argumentos_nombres[i]
local argalt = args[arg.."alt"] or {}
local argtr = args[arg.."tr"] or {}
local argnum = args[arg.."num"] or {}
local argnota = args[arg.."nota"] or {}
if arg == "rima" and argum and idioma then
table.insert(items, "*Rima: [[:Categoría:"..LENG..":Rimas:"..args["rima"].."|"..args["rima"].."]]".."[[Categoría:"..LENG..":Rimas:"..args["rima"].."]]\n")
elseif arg == "ac" and argum then
local acentuacion_tabla = {
['m'] = 'monosílaba',
['a'] = 'aguda',
['l'] = 'llana',
['g'] = 'llana',
['e'] = 'esdrújula',
['s'] = 'sobreesdrújula',
['d'] = 'doble',
}
local acento = argum == "mente" and "doble" or acentuacion_tabla[argum:sub(1,1)]
local acento_cat = acento == "doble" and "con 2 sílabas tónicas" or acento.."s"
if acento and sk then
table.insert(items, "*Acentuación: "..acento..'[[Categoría:'..LENG..':Palabras '..acento_cat.."|"..sk..']]\n')
end
elseif arg == "ls" and argum then
local l_silabica_tabla = {
[1] = 'monosílaba',
[2] = 'bisílaba',
[3] = 'trisílaba',
[4] = 'tetrasílaba',
[5] = 'pentasílaba',
[6] = 'hexasílaba',
[7] = 'heptasílaba',
[8] = 'octosílaba',
[9] = 'eneasílaba',
[10] = 'decasílaba',
[11] = 'endecasílaba',
[12] = 'dodecasílaba',
}
local l_silabica = l_silabica_tabla[argum] or argum
if sk then
if type(l_silabica) == 'number' then
table.insert(items, "*Longitud silábica: "..tostring(l_silabica)..'[[Categoría:'..LENG..':Palabras con más de doce sílabas'.."|"..sk..']]\n')
else
table.insert(items, "*Longitud silábica: "..l_silabica..'[[Categoría:'..LENG..':Palabras '..l_silabica..'s'..'|'..sk..']]\n')
end
end
elseif type(argum) == "string" then
table.insert(items, "*"..argnombre..": "..argum..'\n')
elseif type(argum) == "table" and #argum > 0 then
table.insert(items, "*"..argnombre..": ")
for j,_ in ipairs(argum) do
local argval = argumentos_links[i] and ("[["..argum[j]..(argalt[j] and "|"..argalt[j] or "").."]]") or argum[j]
table.insert(items, (j>1 and ", " or "")..argval..(argtr[j] and " ("..argtr[j]..")" or "")..(argnum[j] and " ("..argnum[j]..")" or "")..(argnota[j] and frame:extensionTag("ref", argnota[j]) or ""))
end
table.insert(items, '\n')
end
end
--table.insert(items, '\n')
--table.insert(items, require("Módulo:TemplateStyles")("Plantilla:pron-graf/styles.css"))
return table.concat(items)
end
return export