local p = local calculators =
-- Global importslocal getArgs = require('Module:Arguments').getArgslocal math = require "Module:Math"local round = math._precision_formatlocal concat = table.concatlocal format = string.formatlocal insert = table.insert
-- Statisticslocal stats, totallocal top, high, mid, lowlocal fa, a, ga, b, c, start, stublocal taskForce
-- Utilitylocal function pad(number) return round(tostring(number), '3')end
local function getCount(type) return stats[type] or 0end
-- Setuplocal function setup top = getCount(taskForce .. 'topFA') + getCount(taskForce .. 'topA') + getCount(taskForce .. 'topGA') + getCount(taskForce .. 'topB') + getCount(taskForce .. 'topC') + getCount(taskForce .. 'topStart') + getCount(taskForce .. 'topStub') high = getCount(taskForce .. 'highFA') + getCount(taskForce .. 'highA') + getCount(taskForce .. 'highGA') + getCount(taskForce .. 'highB') + getCount(taskForce .. 'highC') + getCount(taskForce .. 'highStart') + getCount(taskForce .. 'highStub') mid = getCount(taskForce .. 'midFA') + getCount(taskForce .. 'midA') + getCount(taskForce .. 'midGA') + getCount(taskForce .. 'midB') + getCount(taskForce .. 'midC') + getCount(taskForce .. 'midStart') + getCount(taskForce .. 'midStub') low = getCount(taskForce .. 'lowFA') + getCount(taskForce .. 'lowA') + getCount(taskForce .. 'lowGA') + getCount(taskForce .. 'lowB') + getCount(taskForce .. 'lowC') + getCount(taskForce .. 'lowStart') + getCount(taskForce .. 'lowStub') fa = getCount(taskForce .. 'topFA') + getCount(taskForce .. 'highFA') + getCount(taskForce .. 'midFA') + getCount(taskForce .. 'lowFA') a = getCount(taskForce .. 'topA') + getCount(taskForce .. 'highA') + getCount(taskForce .. 'midA') + getCount(taskForce .. 'lowA') ga = getCount(taskForce .. 'topGA') + getCount(taskForce .. 'highGA') + getCount(taskForce .. 'midGA') + getCount(taskForce .. 'lowGA') b = getCount(taskForce .. 'topB') + getCount(taskForce .. 'highB') + getCount(taskForce .. 'midB') + getCount(taskForce .. 'lowB') c = getCount(taskForce .. 'topC') + getCount(taskForce .. 'highC') + getCount(taskForce .. 'midC') + getCount(taskForce .. 'lowC') start = getCount(taskForce .. 'topStart') + getCount(taskForce .. 'highStart') + getCount(taskForce .. 'midStart') + getCount(taskForce .. 'lowStart') stub = getCount(taskForce .. 'topStub') + getCount(taskForce .. 'highStub') + getCount(taskForce .. 'midStub') + getCount(taskForce .. 'lowStub') total = top + high + mid + lowend
-- Calculators
function constantGenerator(classes, importances, func) local constants = for class,classValue in pairs(classes) do for imp,impValue in pairs(importances) do constants[imp .. class] = func(classValue, impValue) end end return constantsend
function calculators.constant(classes) local importances = return constantGenerator(classes, importances, function (class, importance) return class end)end
function calculators.linear(classes, importances) return constantGenerator(classes, importances, function (class, importance) return class * importance end)end
function calculators.exponential(classes, importances) return constantGenerator(classes, importances, function (class, importance) return class ^ importance end)end
function sumOfCountsWithConstantMultipliers(constants) local sum = 0.0 for classImp,multiplier in pairs(constants) do sum = sum + (multiplier * getCount(taskForce .. classImp)) end return sumend
function calculators.sum(constants) return sumOfCountsWithConstantMultipliers(constants)end
function calculators.average(constants) return sumOfCountsWithConstantMultipliers(constants) / totalend
-- Statistics
local function original local classes = return calculators.sum(calculators.constant(classes))end
local function originalRelative local classes = return calculators.average(calculators.constant(classes))end
local function importanceAdjusted local classes = local importances = return calculators.average(calculators.linear(classes, importances))end
local function reverseImportanceAdjusted local classes = local importances = return calculators.average(calculators.linear(classes, importances))end
local function exponentialImportanceAdjusted local classes = local importances = return calculators.average(calculators.exponential(classes, importances))end
---- Ratioslocal function importanceRatio return (2*top + 1.5*high + 1*mid + 0.5*low) / totalend
local function importanceAdjustedRatio return importanceAdjusted / originalend
local function reverseImportanceAdjustedRatio return reverseImportanceAdjusted / originalend
-- Table definitionslocal columns =
function p._row(rowTaskForce) taskForce = rowTaskForce setup local cells = for k,v in ipairs(columns) do insert(cells, pad(v[2])) end return '| ' .. concat(cells, ' || ')end
function p.row(frame) stats = getArgs(frame) return p._row()end
function p.header(frame) return p._headerend
function p._header local headers = for k,v in ipairs(columns) do insert(headers, v[1]) end return '! ' .. concat(headers, ' !! ')end
local taskForces =
local shields =
local function fullRow(taskForce) local headerTemplate = '! scope="row" |' local image = format("", shields[taskForce]) local link = taskForce
function p._wikiwork rows = ') return concat(rows, "\n|-\n")end
function p.wikiwork(frame) stats = getArgs(frame) return p._wikiworkend
return p