local p = ;
local function majority (frame)
-- input args:-- n-total-arbs, n-inactive-arbs, n-recused-arbs, n-abstained-arbs, n-is-motion
local acm if frame.args.motion
"plural" then acm = math.floor((frame.args.active - (frame.args.inactive + frame.args.recused + frame.args.abstain)) / 2) + 1 else acm = math.floor((frame.args.active - (frame.args.inactive + frame.args.recused)) / 2) + 1 end
return acm
end
local function active (frame)
return frame.args.active - frame.args.inactive - frame.args.recused
end
p.readactive = function (frame) -- cast stuff to numbers local nArbitrators = tonumber(frame.args.active) local nInactive = tonumber(frame.args.inactive) local nRecused = tonumber(frame.args.recused) local nAbstain = tonumber(frame.args.abstain)
-- determine if we have a case, motion, or motions local proceeding = "this case" if frame.args.motion
"plural" then proceeding = "these motions" end
local out_text = "For " .. proceeding .. ", there are " .. active(frame) .. " active arbitrators. "
-- report on inactive and recused arbs that are subtracted out of all majorities local subtract_text
if nInactive > 0 or nRecused > 0 then local arb = "arbitrator" subtract_text = "There is "
if (nInactive + nRecused) > 1 then arb = "arbitrators" subtract_text = "There are " end
if nInactive < 1 then subtract_text = subtract_text .. " " .. frame.args.recused .. " recused " .. arb .. ". " elseif nRecused < 1 then subtract_text = subtract_text .. " " .. frame.args.inactive .. " inactive " .. arb .. ". " else subtract_text = subtract_text .. " " .. frame.args.recused .. " recused and " .. frame.args.inactive .. " inactive " .. arb .. ". " end out_text = out_text .. subtract_text end
-- now give majority count (or abstains + majority count for motions) local maj_text if frame.args.motion
"plural" then -- plural or not plural arbitrators local arb_text = "is 1 abstaining arbitrator, " if (nAbstain > 1) then arb_text = "are " .. frame.args.abstain .. " abstaining arbitrators, " end maj_text = "Since there " .. arb_text else maj_text = "Therefore, " end maj_text = maj_text .. majority(frame) .. " support or oppose votes are a majority." out_text = out_text .. maj_text
return out_textend
p.abstentionrange = function (frame) local out_text = "0–1" if math.fmod(active(frame),2)
p.abstention_maj_r1 = function (frame) return majority (frame) end
p.abstention_maj_r2 = function (frame) return majority (frame) - 1end
p.abstention_maj_r3 = function (frame) return majority (frame) - 2end
return p