Mòdul:it-general: diferència entre les revisions
Contingut suprimit Contingut afegit
accent en diftong decreixent paroxíton |
dígraf qu i monosíl·labs amb diftong |
||
Línia 82: | Línia 82: | ||
end |
end |
||
local sil = mw.ustring.lower(mot) |
local sil = mw.ustring.lower(mot) |
||
sil = string.gsub(sil, "qu", "11") |
|||
-- triftongs |
-- triftongs |
||
sil = mw.ustring.gsub(sil, "iu[aàeèéoòó]", "022") |
sil = mw.ustring.gsub(sil, "iu[aàeèéoòó]", "022") |
||
Línia 229: | Línia 230: | ||
-- Vocal a accentuar, des del final |
-- Vocal a accentuar, des del final |
||
local accent = 2 |
local accent = 2 |
||
if |
if string.find(mot, "^[^aeiou]+[aeiou]+$") then -- monosíl·ab |
||
if not (string.find(mot, "[ae][iu]$") or string.find(mot, "[ou]i$")) then -- ... sense diftong creixent |
|||
accent = 1 |
|||
⚫ | |||
elseif mw.ustring.find(mot, "i[ao]$") or mw.ustring.find(mot, "qu[aeio]$") then |
|||
accent = 3 |
accent = 3 |
||
elseif string.find(mot, "[ae][iu][^aeoiu]+[aeoiu]") or string.find(mot, "[ou]i[^aeoiu]+[aeoiu]") then |
elseif string.find(mot, "[ae][iu][^aeoiu]+[aeoiu]") or string.find(mot, "[ou]i[^aeoiu]+[aeoiu]") then -- diftong decreixent paroxíton |
||
accent = 3 |
accent = 3 |
||
elseif not mw.ustring.find(mot, "[aeiou]$") then |
elseif not mw.ustring.find(mot, "[aeiou]$") then |
||
accent = 1 |
accent = 1 |
||
Línia 262: | Línia 267: | ||
-- Pronunciació |
-- Pronunciació |
||
function export.pron( |
function export.pron(mot) |
||
if type(mot) == "table" then mot = mot.args[1] or mw.title.getCurrentTitle().text end |
|||
if mot == "" then |
|||
mot = mw.title.getCurrentTitle().text |
|||
⚫ | |||
mot = export._sil(mw.ustring.lower(mot)) |
mot = export._sil(mw.ustring.lower(mot)) |
||
-- dígrafs |
-- dígrafs |
||
mot = mw.ustring.gsub(mot, "ch", "k") |
mot = mw.ustring.gsub(mot, "ch", "k") |
||
mot = mw.ustring.gsub(mot, "qu", "kw") |
|||
mot = mw.ustring.gsub(mot, "gn", "ɲ") |
mot = mw.ustring.gsub(mot, "gn", "ɲ") |
||
-- consonants |
-- consonants |
Revisió del 23:57, 10 gen 2016
A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]
-- Funcions generals per italià. Inacabat, en proves.
local export = {}
-- Clau d'ordenació per a categories en italià
local senseDiacritics = {
["À"] = "A", ["à"] = "a",
["È"] = "E", ["è"] = "e", ["É"] = "E", ["é"] = "e",
["Ì"] = "I", ["ì"] = "i",
["Ò"] = "O", ["ò"] = "o", ["Ó"] = "O", ["ó"] = "o",
["Ù"] = "U", ["ù"] = "u"}
local senseSignes = {
["/"] = "",
["-"] = "",
["."] = "",
["'"] = " "}
local ordreAccents = { -- ordre eéè simulat amb ordre Unicode eèéê
["è"] = "ê",
["ò"] = "ô"}
function export.ordena(mot)
if type(mot) == "table" then mot = mot.args[1] end -- des de plantilles via invoke o des de mòduls via require
if mot == "" or mot == nil then
mot = mw.title.getCurrentTitle().text
end
local clau -- format complet: "clau1!clau2!clau3!mot"
local clau1 -- clau primària: en minúscules i sense diacrítics ni signes
local clau2 -- clau secundària: prioritat dels diacrítics eéè
local clau3 -- clau terciària: prioritat minúscules > majúscules
-- clau quaternària: prioritat sense signes > amb signes
local motSenseSignes = mw.ustring.gsub(mot, ".", senseSignes)
local motLower = mw.ustring.lower(motSenseSignes)
clau1 = mw.ustring.gsub(motLower, ".", senseDiacritics)
if clau1 == mot then
return clau1
end
clau2 = mw.ustring.gsub(motLower, ".", ordreAccents)
clau3 = mw.ustring.gsub(motSenseSignes, ".", senseDiacritics)
if clau1 == motLower then
clau = clau1 .. "!"
else
clau = clau1 .. "!" .. clau2
end
if clau3 ~= clau1 then
clau = clau .. "!" .. clau3
elseif motSenseSignes ~= mot then
clau = clau .. "!"
end
if motSenseSignes ~= mot then
clau = clau .."!" .. mot
end
return clau
end
function export._ordena(mot)
-- Funció que es pot usar en altres mòduls via require
-- Pendent d'eliminar una vegada substituïda
return export.ordena(mot)
end
--[[
Sil·labificació
marcatge intern: vocals 0, obertures 1, codes 2
síl·laba: ·(1*)0(2*)·
]]
function export.sil(mot, accent)
if type(mot) == "table" then
accent = mot.args[2]
mot = mot.args[1]
end
if mot == "" or mot == nil then
mot = mw.title.getCurrentTitle().text
end
-- Si no hi ha cap accent el posem
if accent ~= "" and accent ~= nil then
local from = mw.ustring.gsub(accent, ".", senseDiacritics)
mot = mw.ustring.gsub(mot, from, accent, 1)
end
if not mw.ustring.find(mot, "[àèéìòóù]") then
mot = export.accent(mot)
end
local sil = mw.ustring.lower(mot)
sil = string.gsub(sil, "qu", "11")
-- triftongs
sil = mw.ustring.gsub(sil, "iu[aàeèéoòó]", "022")
sil = mw.ustring.gsub(sil, "[iu][aàeèéoòó]i$", "022")
-- diftongs creixents
sil = mw.ustring.gsub(sil, "i[aàeèéoòóuù]", "02")
sil = mw.ustring.gsub(sil, "u[aàeèéiìoòó]", "02")
-- diftongs decreixents
sil = mw.ustring.gsub(sil, "[aàeèé][iu]", "02")
sil = mw.ustring.gsub(sil, "[oòóù]i", "02")
-- Nuclis vocàlics
sil = mw.ustring.gsub(sil, "[aàeèéiìoòóuù]", "0")
-- Codes
sil = mw.ustring.gsub(sil, "[lmnr]([^0])", "2%1")
-- Obertures inseparables, digrammi
sil = mw.ustring.gsub(sil, "[cg]h", "11")
sil = mw.ustring.gsub(sil, "[bcfgġpst]l", "11")
sil = mw.ustring.gsub(sil, "[st]m", "11")
sil = mw.ustring.gsub(sil, "[gp]n", "11")
sil = mw.ustring.gsub(sil, "[bcdfgpstv]r", "11")
sil = mw.ustring.gsub(sil, "ps", "11")
-- Obertures s impura
sil = mw.ustring.gsub(sil, "s1", "11")
sil = mw.ustring.gsub(sil, "ss", "21")
sil = mw.ustring.gsub(sil, "s[^0]", "11")
-- Obertures simples
sil = mw.ustring.gsub(sil, "%l0", "10")
-- Codes finals
sil = mw.ustring.gsub(sil, "%l$", "2")
sil = mw.ustring.gsub(sil, "%l2$", "22")
sil = mw.ustring.gsub(sil, "%l22$", "222")
-- Codes interiors
sil = mw.ustring.gsub(sil, "%l([12])", "2%1")
-- Separació de síl·labes
local anterior = ""
local motSil = {}
for i = 1, mw.ustring.len(mot) do
actual = mw.ustring.sub(sil,i,i)
if (actual == "0" or actual == "1") and (anterior == "0" or anterior == "2") then
table.insert(motSil, "·")
end
table.insert(motSil, mw.ustring.sub(mot,i,i))
anterior = actual
end
return table.concat(motSil)
end
function export._sil(mot)
-- Funció per usar en altres mòduls via require
-- Pendent d'eliminar una vegada substituïda
return export.sil(mot)
end
function export.accent(mot)
if type(mot) == "table" then mot = mot.args[1] end -- des de plantilles via invoke o des de mòduls via require
if mot == "" or mot == nil then
mot = mw.title.getCurrentTitle().text
end
-- Casos é generals
mot = mw.ustring.gsub(mot, "esero$", "ésero")
mot = mw.ustring.gsub(mot, "erono$", "érono")
mot = mw.ustring.gsub(mot, "essero$", "éssero")
mot = mw.ustring.gsub(mot, "ecc(h?)i([ao])$", "écc%1i%2")
mot = mw.ustring.gsub(mot, "ecc(h?[ei])$", "écc%1")
mot = mw.ustring.gsub(mot, "ecc([ao])$", "écc%1")
mot = mw.ustring.gsub(mot, "emplic([ei])$", "émplic%1")
mot = mw.ustring.gsub(mot, "eggi([ao])$", "éggi%1")
mot = mw.ustring.gsub(mot, "egg([ei])$", "égg%1")
mot = mw.ustring.gsub(mot, "egn([aeio])$", "égn%1")
mot = mw.ustring.gsub(mot, "egr([aeio])$", "égr%1")
mot = mw.ustring.gsub(mot, "es([aeio])$", "és%1")
mot = mw.ustring.gsub(mot, "esc(h?[aeio])$", "ésc%1")
mot = mw.ustring.gsub(mot, "et([aeio])$", "ét%1")
mot = mw.ustring.gsub(mot, "ett([aeio])$", "étt%1")
mot = mw.ustring.gsub(mot, "evol([ei])$", "évol%1")
mot = mw.ustring.gsub(mot, "evr([aeio])$", "évr%1")
mot = mw.ustring.gsub(mot, "ezz([aeio])$", "ézz%1")
mot = mw.ustring.gsub(mot, "ment([aeio])$", "mént%1")
-- Casos ó generals
mot = mw.ustring.gsub(mot, "oc([ei])$", "óc%1")
mot = mw.ustring.gsub(mot, "ogn([aeio])$", "ógn%1")
mot = mw.ustring.gsub(mot, "oi([aeio])$", "ói%1")
mot = mw.ustring.gsub(mot, "omplic([aeio])$", "ómplic%1")
mot = mw.ustring.gsub(mot, "osero$", "ósero")
mot = mw.ustring.gsub(mot, "([^fu])on([aei])$", "%1ón%2")
mot = mw.ustring.gsub(mot, "([^aeio])fon([aei])$", "%1fón%2")
mot = mw.ustring.gsub(mot, "onci([aeio])$", "ónci%1")
mot = mw.ustring.gsub(mot, "ont([aeio])$", "ónt%1")
mot = mw.ustring.gsub(mot, "onz([aeio])$", "ónz%1")
mot = mw.ustring.gsub(mot, "onzol([aeio])$", "ónzol%1")
mot = mw.ustring.gsub(mot, "orci([ao])$", "órci%1")
mot = mw.ustring.gsub(mot, "orc([ei])$", "órc%1")
mot = mw.ustring.gsub(mot, "orn([aeio])$", "órn%1")
mot = mw.ustring.gsub(mot, "or([ei])$", "ór%1")
mot = mw.ustring.gsub(mot, "os([aeio])$", "ós%1")
mot = mw.ustring.gsub(mot, "ozz([io])$", "ózz%1")
mot = mw.ustring.gsub(mot, "ond([aeio])$", "ónd%1")
-- Casos de estrúixoles generals
mot = mw.ustring.gsub(mot, "a([bcdfglmnprsṣtvzẓ][bcdfghmnprstvzẓ]?l?)i([cdlmt]h?)([aeio])$", "à%1i%2%3")
mot = mw.ustring.gsub(mot, "e([bcdfglmnpqrsṣtvzẓ][bcdfghmnprstvzẓ]?l?)i([cdlmt]h?)([aeio])$", "è%1i%2%3")
mot = mw.ustring.gsub(mot, "i([bcdfglmnpqrsṣtvzẓ][bcdfghmnprstvzẓ]?l?)i([cdlmt]h?)([aeio])$", "ì%1i%2%3")
mot = mw.ustring.gsub(mot, "o([bcdfglmnpqrsṣtvzẓ][bcdfghmnprstvzẓ]?l?)i([cdlmt]h?)([aeio])$", "ò%1i%2%3")
mot = mw.ustring.gsub(mot, "u([bcdfglmnpqrsṣtvzẓ][bcdfghmnprstvzẓ]?l?)i([cdlmt]h?)([aeio])$", "ù%1i%2%3")
mot = mw.ustring.gsub(mot, "acciol([aeio])$", "àcciol%1")
mot = mw.ustring.gsub(mot, "a([sc]?)cher([aeio])$", "à%1cher%2")
mot = mw.ustring.gsub(mot, "afo([bn][aeio])$", "àfo%1")
mot = mw.ustring.gsub(mot, "ag(g?)in([ei])$", "àg%1in%2")
mot = mw.ustring.gsub(mot, "arono$", "àrono")
mot = mw.ustring.gsub(mot, "a([smc]?[bcgmnpt][pbndt]?)ol([aeio])$", "à%1ol%2")
mot = mw.ustring.gsub(mot, "asser([aeio])$", "àsser%1")
mot = mw.ustring.gsub(mot, "avol([aeio])$", "àvol%1")
mot = mw.ustring.gsub(mot, "e([smc]?[bcgmnpt][pbndt]?)ol([aeio])$", "è%1ol%2")
mot = mw.ustring.gsub(mot, "efon([io])$", "èfon%1")
mot = mw.ustring.gsub(mot, "evol([ao])$", "èvol%1")
mot = mw.ustring.gsub(mot, "i([sc]?)cher([aeio])$", "ì%1cher%2")
mot = mw.ustring.gsub(mot, "icciol([aeio])$", "ìcciol%1")
mot = mw.ustring.gsub(mot, "ie([dt])ere$", "iè%1ere")
mot = mw.ustring.gsub(mot, "ifo([nr][aeio])$", "ìfo%1")
mot = mw.ustring.gsub(mot, "i([fn]?)fer([aeio])$", "ì%1fer%2")
mot = mw.ustring.gsub(mot, "i([ng]?)gere$", "ì%1gere")
mot = mw.ustring.gsub(mot, "ig(g?)in([ei])$", "ìg%1in%2")
mot = mw.ustring.gsub(mot, "irono$", "ìrono")
mot = mw.ustring.gsub(mot, "i([smc]?[bcgmnpt][pbndt]?)ol([aeio])$", "ì%1ol%2")
mot = mw.ustring.gsub(mot, "issero$", "ìssero")
mot = mw.ustring.gsub(mot, "ivol([aeio])$", "ìvol%1")
mot = mw.ustring.gsub(mot, "o([smc]?[bcgmnpt][pbndt]?)ol([aeio])$", "ò%1ol%2")
mot = mw.ustring.gsub(mot, "o([sc]?)cher([aeio])$", "ò%1cher%2")
mot = mw.ustring.gsub(mot, "or([dg])ere$", "òr%1ere")
mot = mw.ustring.gsub(mot, "ossero$", "òssero")
mot = mw.ustring.gsub(mot, "o(s?)fo([bnr][aeio])$", "ò%1fo%2")
mot = mw.ustring.gsub(mot, "ovol([aeio])$", "òvol%1")
mot = mw.ustring.gsub(mot, "u([sc]?)cher([aeio])$", "ù%1cher%2")
mot = mw.ustring.gsub(mot, "ucciol([aeio])$", "ùcciol%1")
mot = mw.ustring.gsub(mot, "udin([ei])$", "ùdin%1")
mot = mw.ustring.gsub(mot, "ug(g?)in([ei])$", "ùg%1in%2")
mot = mw.ustring.gsub(mot, "uotere$", "uòtere")
mot = mw.ustring.gsub(mot, "u([smc]?[bcgmnpt][pbndt]?)ol([aeio])$", "ù%1ol%2")
mot = mw.ustring.gsub(mot, "urono$", "ùrono")
mot = mw.ustring.gsub(mot, "ussero$", "ùssero")
mot = mw.ustring.gsub(mot, "uvol([aeio])$", "ùvol%1")
mot = mw.ustring.gsub(mot, "uzzol([aeio])$", "ùzzol%1")
if mw.ustring.find(mot, "[àèéìòóù]") then
return mot
end
-- Altrament, oberta
local accentuar = {["a"]="à", ["e"]="è", ["i"]="ì", ["o"]="ò", ["u"]="ù"}
-- Vocal a accentuar, des del final
local accent = 2
if string.find(mot, "^[^aeiou]+[aeiou]+$") then -- monosíl·ab
if not (string.find(mot, "[ae][iu]$") or string.find(mot, "[ou]i$")) then -- ... sense diftong creixent
accent = 1
end
elseif mw.ustring.find(mot, "i[ao]$") or mw.ustring.find(mot, "qu[aeio]$") then
accent = 3
elseif string.find(mot, "[ae][iu][^aeoiu]+[aeoiu]") or string.find(mot, "[ou]i[^aeoiu]+[aeoiu]") then -- diftong decreixent paroxíton
accent = 3
elseif not mw.ustring.find(mot, "[aeiou]$") then
accent = 1
end
local vocals = 0
for i = mw.ustring.len(mot), 1, -1 do
local lletra = mw.ustring.sub(mot, i, i)
if mw.ustring.find(lletra, "[aeiou]") then
vocals = vocals + 1
if vocals == accent then
local accentuat = mw.ustring.gsub(lletra, ".", accentuar) .. mw.ustring.sub(mot, i+1)
if i>1 then
accentuat = mw.ustring.sub(mot, 1, i-1) .. accentuat
end
return accentuat
end
end
end
if not mw.ustring.find(mot, "[àèéìòóù]") then
mot = mw.ustring.gsub(mot, "[aeiou]", accentuar, 1)
end
return mot
end
function export._accent(mot)
-- Pendent d'eliminar una vegada substituïda
return export.accent(mot)
end
-- Pronunciació
function export.pron(mot)
if type(mot) == "table" then mot = mot.args[1] or mw.title.getCurrentTitle().text end
mot = export._sil(mw.ustring.lower(mot))
-- dígrafs
mot = mw.ustring.gsub(mot, "ch", "k")
mot = mw.ustring.gsub(mot, "qu", "kw")
mot = mw.ustring.gsub(mot, "gn", "ɲ")
-- consonants
mot = mw.ustring.gsub(mot, "y", "j")
mot = mw.ustring.gsub(mot, "q", "k")
mot = mw.ustring.gsub(mot, "sci([aàoòóuù)])", "ʃ%1")
mot = mw.ustring.gsub(mot, "sc([eèéiì])", "ʃ%1")
mot = mw.ustring.gsub(mot, "ci([aàoòóuù])", "tʃ%1")
mot = mw.ustring.gsub(mot, "c([eèéiì])", "tʃ%1")
mot = mw.ustring.gsub(mot, "c·tʃ", "t·tʃ")
mot = mw.ustring.gsub(mot, "c", "k")
mot = mw.ustring.gsub(mot, "gi([aàoòóuù])", "dʒ%1")
mot = mw.ustring.gsub(mot, "g([eèéiì])", "dʒ%1")
mot = mw.ustring.gsub(mot, "g·dʒ", "d·dʒ")
mot = mw.ustring.gsub(mot, "g([aàoòóuù])", "g%1")
mot = mw.ustring.gsub(mot, "gh", "g")
mot = mw.ustring.gsub(mot, "ġl", "ɡl")
mot = mw.ustring.gsub(mot, "([^n])·gli([aàeèéoòóuù])", "%1·ʎ%2")
mot = mw.ustring.gsub(mot, "([^n])·gl([iì])", "%1·ʎ%2")
mot = mw.ustring.gsub(mot, "^gli([aàeèéoòóuù])", "ʎ%1")
mot = mw.ustring.gsub(mot, "^gl([iì])", "ʎ%1")
mot = mw.ustring.gsub(mot, "([aàeèéiìoòóuù])·ʎ", "%1ʎ·ʎ")
mot = mw.ustring.gsub(mot, "n·gl([iì])", "ŋ·gl%1")
mot = mw.ustring.gsub(mot, "([aàeèéiìoòóuù])·ɲ", "%1ɲ·ɲ")
mot = mw.ustring.gsub(mot, "n·([kg])", "ŋ·%1")
mot = mw.ustring.gsub(mot, "n([kg])", "ŋ%1")
mot = mw.ustring.gsub(mot, "h", "")
mot = mw.ustring.gsub(mot, "([mn])·([fv])", "ɱ·%2")
mot = mw.ustring.gsub(mot, "([aàeèéiìoòóuù])·ʃ", "%1ʃ·ʃ")
mot = mw.ustring.gsub(mot, "z·z", "t·ts")
mot = mw.ustring.gsub(mot, "([aàeèéiìoòóuù])·z", "%1t·ts")
mot = mw.ustring.gsub(mot, "z", "ts")
mot = mw.ustring.gsub(mot, "ẓ·ẓ", "d·dz")
mot = mw.ustring.gsub(mot, "([aàeèéiìoòóuù])·ẓ", "%1d·dz")
mot = mw.ustring.gsub(mot, "ẓ", "dz")
-- essa sonora o sorda
mot = mw.ustring.gsub(mot, "s([bdglmnrv])", "z%1")
mot = mw.ustring.gsub(mot, "ṣ", "z")
mot = mw.ustring.gsub(mot, "x", "ks")
-- vocals
mot = mw.ustring.gsub(mot, "i([aàeèéoòóuù])", "j%1")
mot = mw.ustring.gsub(mot, "i.([aàeèéoòóuù])", "i·%1")
mot = mw.ustring.gsub(mot, "ɲj", "ɲ")
mot = mw.ustring.gsub(mot, "u([aàeèéiìoòó])", "w%1")
mot = mw.ustring.gsub(mot, "u.([aàeèéiìoòó])", "u·%1")
-- accent
if mw.ustring.find(mot, "[àèéìóòù]") then
mot = mw.ustring.gsub(mot, "·(%l-[àèéìòóù])", "ˈ%1")
else
mot = mw.ustring.gsub(mot, "·(%l-)·(%l-)$", "ˈ%1·%2")
end
if not mw.ustring.find(mot, "ˈ") then -- monosíl·lab o accent en la primera
mot = "ˈ" .. mot
end
mot = mw.ustring.gsub(mot, "è", "ɛ")
mot = mw.ustring.gsub(mot, "ò", "ɔ")
mot = mw.ustring.gsub(mot, ".", senseDiacritics)
mot = mw.ustring.gsub(mot, "tʃ", "t͡ʃ")
mot = mw.ustring.gsub(mot, "dʒ", "d͡ʒ")
mot = mw.ustring.gsub(mot, "g", "ɡ")
mot = mw.ustring.gsub(mot, "ts", "t͡s")
mot = mw.ustring.gsub(mot, "dz", "d͡z")
return '/' .. mw.ustring.gsub(mot, "·", ".") .. '/'
end
return export