in reply to Re: Letter frequencies
in thread Letter frequencies
Update
yes, it was.
I changed
s/ //g;
to
s/\W//g;
thanks, Albannach! (wave)
# # # use strict; my %symbol; my %tri; my @trikeys; my $line; my $ctr; print "Processing file...\n"; while ($line = <>) { for (split /\W/,$line) { #discard all non-alpha. be *greedy* s/\W//g; (length($_)>2) && $symbol{lc($_)}++; } } print "Collecting trigraphs...\n"; foreach (keys %symbol){ for ($ctr=0; $ctr <= (length($_)-3);$ctr++) { $tri{lc(substr ($_,$ctr,3))}+= $symbol{$_}; } } @trikeys = sort {$tri{$b} <=> $tri{$a}} keys %tri; print "Total Trigraphs : ",$#trikeys,"\n"; print "Trigraph\tCount\n"; foreach (@trikeys) { print "$_\t$tri{$_}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Letter frequencies
by Dominus (Parson) on Nov 24, 2000 at 17:29 UTC |