Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -0,0 +1,27 @@
void main() {
import std.stdio, std.string, std.range, std.algorithm, std.ascii;
immutable src = "unixdict.txt";
const words = src.File.byLineCopy.map!strip.filter!(w => w.all!isAlpha).array;
immutable table = makeTrans("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
"2223334445556667777888999922233344455566677778889999");
string[][string] dials;
foreach (const word; words)
dials[word.translate(table)] ~= word;
auto textonyms = dials.byPair.filter!(p => p[1].length > 1).array;
writefln("There are %d words in %s which can be represented by the digit key mapping.", words.length, src);
writefln("They require %d digit combinations to represent them.", dials.length);
writefln("%d digit combinations represent Textonyms.", textonyms.length);
"\nTop 5 in ambiguity:".writeln;
foreach (p; textonyms.schwartzSort!(p => -p[1].length).take(5))
writefln(" %s => %-(%s %)", p[]);
"\nTop 5 in length:".writeln;
foreach (p; textonyms.schwartzSort!(p => -p[0].length).take(5))
writefln(" %s => %-(%s %)", p[]);
}