local export = {}
local header = [[
{| class="wikitable sortable" style="text-align:center; background-color:#fdfdfd"
|-
! Rank !! Word !! Count !! Freq (ppm) !! Cumul (%) !! Additional information
]]
local footer = ]
local function link(word, lang_code, lang_name, script)
return '<span class="' .. script .. '" lang="' .. lang_code .. '">[['
.. word .. '#' .. lang_name .. '|' .. word .. ']]</span>'
end
function export.list(frame)
local args = require "Module:table".shallowcopy(frame.args)
if #args % 3 ~= 0 then
error(("The number of arguments should be a multiple of 3, but is %d")
:format(#args))
end
local init_rank, init_count, total_count = unpack(args, 1, 3)
local Array = require "Module:array"
local output = Array()
output:insert(header)
local rank = init_rank
local cumul_count = init_count
for i = 4, #args, 3 do
local word, count, details= unpack(args, i, i + 3)
cumul_count = cumul_count +count
freq = math.floor(count / total_count * 100000000)/100
cumul = math.floor(cumul_count / total_count * 10000)/100
output:insert(("|-style='vertical-align:top'\n|%s|| style='text-align: left' |%s||%s||%s||%s||style='text-align: left' |%s\n"):format(
rank, word, count, freq, cumul, details))
--output:insert(("|-style='vertical-align:top'\n|%s||%s||%s||%s||%s||%s\n"):format(
-- rank, word, count, freq, cumul, details))
rank = rank +1
end
output:insert(footer)
return output:concat()
end
function export.list2(frame)
local args = require "Module:table".shallowcopy(frame.args)
if #args % 6 ~= 0 then
error(("The number of arguments should be a multiple of 6, but is %d")
:format(#args))
end
local Array = require "Module:array"
local output = Array()
output:insert(header)
local rank = init_rank
local cumul_count = init_count
for i = 1, #args, 6 do
local rank, word, count, freq, cumul, details= unpack(args, i, i + 5)
output:insert(("|-\n| %s || %s || %s || %s || %s || %s\n"):format(
rank, word, count, freq, cumul, details))
end
output:insert(footer)
return output:concat()
end
return export