summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-languages-frequencies.lua
blob: 16213a4127198368c2613eb8512bebcc59312595 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
if not modules then modules = { } end modules ['s-languages-frequencies'] = {
    version   = 1.001,
    comment   = "companion to s-languages-frequencies.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

moduledata.languages             = moduledata.languages             or { }
moduledata.languages.frequencies = moduledata.languages.frequencies or { }

function moduledata.languages.frequencies.showlist(specification)
    specification = interfaces.checkedspecification(specification)
    local t = languages.frequencies.getdata(specification.language or languages.current())
    context.starttabulate { "|lT|cw(2em)|r|" }
    context.NC()
    context.formatted.rlap("%s: %p",t.language,languages.frequencies.averagecharwidth(t.language))
    context.NC()
    context.NC()
    context.NR()
    context.HL()
    for k, v in table.sortedhash(t.frequencies) do
        context.NC()
        context("%U",k)
        context.NC()
        context("%c",k)
        context.NC()
        context("%0.3f",v)
        context.NC()
        context.NR()
    end
    context.stoptabulate()
end