blob: 43d59a2d1310aa26497dd45e2f811090d79f2531 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
%D \module
%D [ file=s-lan-06,
%D version=2013.03.22,
%D title=\CONTEXT\ Style File,
%D subtitle=Language Environment 6,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\startluacode
languages.tracers = languages.tracers or { }
function languages.tracers.showfrequencies(language)
local t = languages.frequencies.getdata(language or "en")
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
\stopluacode
\unexpanded\def\ShowLanguageFrequencies#1%
{\ctxlua{languages.tracers.showfrequencies("#1")}}
\continueifinputfile{s-lan-06.mkiv}
\starttext
\hsize65\averagecharwidth \input ward \par
\ShowLanguageFrequencies\currentmainlanguage
\stoptext
|