Download or view letterGraph.frink in plain text format
// Program to graph the frequency of letters in English.
freqs = """
1. e (390395169, 12.575645%)
2. t (282039486, 9.085226%)
3. a (248362256, 8.000395%)
4. o (235661502, 7.591270%)
5. i (214822972, 6.920007%)
6. n (214319386, 6.903785%)
7. s (196844692, 6.340880%)
8. h (193607737, 6.236609%)
9. r (184990759, 5.959034%)
10. d (134044565, 4.317924%)
11. l (125951672, 4.057231%)
12. u (88219598, 2.841783%)
13. c (79962026, 2.575785%)
14. m (79502870, 2.560994%)
15. f (72967175, 2.350463%)
16. w (69069021, 2.224893%)
17. g (61549736, 1.982677%)
18. y (59010696, 1.900888%)
19. p (55746578, 1.795742%)
20. b (47673928, 1.535701%)
21. v (30476191, 0.981717%)
22. k (22969448, 0.739906%)
23. x (5574077, 0.179556%)
24. j (4507165, 0.145188%)
25. q (3649838, 0.117571%)
26. z (2456495, 0.079130%)
"""
grams = new dict
for [gram, freq, pct] = freqs =~ %r/^\s*\d+\.\s*(\w+)\s+\((\d+),\s*([0-9\.]+)%/gm
grams@gram = eval[pct]
g = new graphics
num = 0
for [gram, pct] = sort[grams, {|a,b| -( a@1 <=> b@1 ) }]
{
g.color[.9,.9,.9]
g.fillRectSides[num, 0, num+1, -2.7 pct]
g.color[0,0,0]
g.drawRectSides[num, 0, num+1, -2.7 pct]
g.font["SansSerif", 0.15]
g.text[uc[gram] + " = " + format[pct,1,3], num+1/2, 0, "center", "bottom"]
g.font["SansSerif", 1]
g.text[uc[gram], num+1/2, -0.4, "center", "bottom"]
num = num + 1
}
g.show[]
g.write["letters.svg",850,1100]
//g.print[]
Download or view letterGraph.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20218 days, 0 hours, 24 minutes ago.