Usuário(a):Gnosygnu/sandbox/Módulo:Filtros
m = {}
function m.getNumberOfFalsePositives( frame )
text = mw.title.new( 'Wikipédia:Filtro de edições/Análise/Filtro ' .. frame.args[1] ):getContent() if text == nil then -- title does not exist; content is nil; must exit now, or will fail when passing nil to string.gmatch below return 0 end local gen, fp = string.gmatch(text, '{{Ação|%d+|?(%a*)'), 0 for x in gen do if x == 'erro' then fp = fp + 1 end end return fp
end
function m.tabelafp(frame)
local tabela = {} for i, f in ipairs(frame.args) do local num, desc = string.match(f, "(%d%d?%d?):([^\n]*)") text = mw.title.new('Wikipédia:Filtro de edições/Análise/Filtro ' .. num):getContent() if text == nil then -- title does not exist; content is nil; must exit now, or will fail when passing nil to string.gmatch below return 0 end local gen, count, fp = string.gmatch(text, '{{Ação|%d+|?(%a*)'), 0, 0 for x in gen do count = count + 1 if x == 'erro' then fp = fp + 1 end end table.insert(tabela,{num, desc, count, fp, string.gsub(math.floor(fp / count * 1000) / 10 .. ' %', '%.', ',')}) end
wikitext = [=[
]=] for i, f in ipairs(tabela) do wikitext = wikitext .. string.format([=[ ]=], f[1], f[1], f[2], f[1], f[1], f[3], f[4], f[5]) end wikitext = wikitext .. '\nFiltro | Descrição | Ações avaliadas |
Falsos positivos |
Porcentagem |
---|---|---|---|---|
%s | %s (discussão) | %d | %d | %s |
'
return wikitext
end
return m