Textonyms: Difference between revisions

Content deleted Content added
m →‎{{header|Perl 6}}: remove unneeded case insensitivity
→‎{{header|Perl 6}}: much faster version
Line 300:
=={{header|Perl 6}}==
<lang perl6>my $src = 'unixdict.txt';
my @c2d = 0 xx 64, @$_, @$_
given '02223334445556667777888999900000'.comb;
 
my @words = slurp($src).lines.grep(/ ^ <alpha>+ $ /);
 
my @dials = @words.classify: { @c2d[.ords].join }
.trans('abcdefghijklmnopqrstuvwxyz'
=> '22233344455566677778889999');
}
 
my @textonymsnyms = @dials.grep(*: { .value > 1); }
 
say qq:to 'END';
There are {+@words} words in $src which can be represented by the digit key mapping.
They require {+@dials} digit combinations to represent them.
{+@textonymsnyms} digit combinations represent Textonyms.
END
 
say "Top 5 in ambiguity:";
say " ",$_ for @textonymsnyms.sort(-*.value)[^5];
 
say "\nTop 5 in length:";
say " ",$_ for @textonymsnyms.sort(-*.key.chars)[^5];</lang>
{{out}}
<pre>There are 24978 words in unixdict.txt which can be represented by the digit key mapping.