Modulo:Sandbox/Daimona Eaytoy/Test

Da Wikipedia, l'enciclopedia libera.
Vai alla navigazione Vai alla ricerca
--Modulo per la semplificazione di piped link che utilizzano il pipe per rimuovere caratteri speciali.
local p={};
function p.main(frame)
piped = frame.args[1]
orig = frame.args[2]
local esito= orig..'|'..piped

for y=-3,-2 do
for z=-1,0 do
for a=1,2 do
   for b=3,4 do
      for c=5,6 do
         for d=7,9 do
            for e=10,11 do
            	for f=12,14 do
            		for g=15,16 do
	                   if risultato(y,z,a,b,c,d,e,f,g)==piped then esito=orig return esito end
	                end
	            end
	        end
	     end
	  end
   end
end
end
end--fine for

return esito

end--fine funzione main

function risultato(y,z,a,b,c,d,e,f,g)
base={
   ['Á'] = 'A',
   ['ć'] = 'c',
   ['Ć'] = 'C',
   ['Ž'] = 'Z',
   ['ë'] = 'e',
   ['ï'] = 'i',
   ['ă'] = 'a',
   ['ā'] = 'a',
   ['ē'] = 'e',
   ['ř'] = 'r',
   ['í'] = 'i',
   ['ý'] = 'y',
   ['ó'] = 'o',
   ['è'] = 'e',
   ['ě'] = 'e',
   ['ñ'] = 'n'--,
   --[' '] = '-' --dà problemi
	}
lista={
   ['é'] ={
   	   [-3]='e',
   	   [-2]='è'
   	   },
   ['á'] ={
   	   [-1]='a',
   	   [0]='à'
   	   },
   ['-'] ={
   	   [1] = ' ',
   	   [2] = '-'
   	   },
   ['č'] = {
   	   [3] = 'c',
   	   [4] = 'ch'
   	   },
   ['Č'] = {
   	   [3] = 'C',
   	   [4] = 'Ch'
   	   },
   ['ö'] = {
   	   [5] = 'o',
   	   [6] = 'oe'
   	   },
   ['ž'] = {
   	   [7] = 'z',
   	   [8] = 'j',
   	   [9] = 'zh'
   	   },
   ['š'] = {
   	   [10] = 's',
   	   [11] = 'sh'
   	   },
   ['Š'] = {
   	   [10] = 'S',
   	   [11] = 'Sh'
   	   },
   ['j'] = {
   	   [12] = 'y',
   	   [13] = '',
   	   [14] = 'j'
      },
   ['J'] = {
   	   [15] = 'Y',
   	   [16] = 'J'
   	   }
} 

return (mw.ustring.gsub(orig,"(.)", 
function(w) 
  if lista[w]~=nil then
      if lista[w][y]~=nil then return lista[w][y] 
      elseif lista[w][z]~=nil then return lista[w][z]
      elseif lista[w][a]~=nil then return lista[w][a]
      elseif lista[w][b]~=nil then return lista[w][b]
      elseif lista[w][c]~=nil then return lista[w][c]
      elseif lista[w][d]~=nil then return lista[w][d]
      elseif lista[w][e]~=nil then return lista[w][e]
      elseif lista[w][f]~=nil then return lista[w][f]
      elseif lista[w][g]~=nil then return lista[w][g] end
  end
return base[w]
end --fine funzione parametro di gsub
)--fine argomento gsub
)--fine parentesi esterna gsub per output singolo

end--fine funzione "risultato"

return p--return finale