|
|
 |
 |
 |
 |
Perl Programming Language
|
 |
 |
 |
 |
 |
 |
 |
 |
on my desk, as far as I can see
On 2003-12-02, Beable van Polasm wrote: > OOOPS! SORRY! > -----begin deacronymiser.pl---------------------
I hope Beable doesn't mind, but I've modified the program so it will load the dictionary and split it up once, then process more than one acronym in the same command, with an option to generate multiple expansions per acronym, without reloading or resegmenting the dictionary. --- begin example --- $ deacronymiser.pl -n 3 ark perl ARK = Ablution's Recipe Kiloton's ARK = Aplenty Radiogram Kooking ARK = Announcer's Rejoinder Kazoo PERL = Pygmies Eve's Romano's Loped PERL = Philanderer Enhance Rusting Loader PERL = Pudgy Enthusiasm Reps Lifeworks --- end example --- --- begin code --- #!/usr/bin/perl use strict; use warnings; use Getopt::Std ; my (%option, $i, $acronym); getopts("n:", \%option) ; my $count = $option{n} || 1; my %keyed_words = (); load(); while (@ARGV > 0) { $acronym = shift(@ARGV); for ($i=0 ; $i < $count ; $i++) { run($acronym); } }
sub load { my $words_file = "/usr/dict/words"; my @words = (); open WORDS, "<$words_file" or die "can't open $words_file: $!"; while(my $line = <WORDS>) { chomp $line; $line = lc $line; push @words, $line; } close WORDS or die "can't close $words_file: $!"; my ($word, $letter); while(@words) { $word = shift(@words); $letter = lc(substr($word, 0, 1)); push( @{$keyed_words{$letter}}, $word ); } }
sub run { my $acronym = shift; $acronym = lc $acronym; my @letters = split //, $acronym; print uc $acronym, " = "; while (my $letter = shift @letters) { next if $letter !~ m/[a-z]/; my @match_words = @{$keyed_words{$letter}}; my $word = @match_words[rand(@match_words)]; print ucfirst $word, " "; } print "\n"; }
--- end code ---
"Adam Funk" <a24@ducksburg.com> wrote
> > OOOPS! SORRY! > > -----begin deacronymiser.pl--------------------- > I hope Beable doesn't mind, but I've modified the program so it will > load the dictionary and split it up once, then process more than one > acronym in the same command, with an option to generate multiple > expansions per acronym, without reloading or resegmenting the > dictionary. > --- begin example --- > $ deacronymiser.pl -n 3 ark perl > ARK = Ablution's Recipe Kiloton's > ARK = Aplenty Radiogram Kooking > ARK = Announcer's Rejoinder Kazoo > PERL = Pygmies Eve's Romano's Loped > PERL = Philanderer Enhance Rusting Loader > PERL = Pudgy Enthusiasm Reps Lifeworks > --- end example --- > --- begin code --- > #!/usr/bin/perl > use strict; > use warnings; > use Getopt::Std ; > my (%option, $i, $acronym); > getopts("n:", \%option) ; > my $count = $option{n} || 1; > my %keyed_words = (); > load(); > while (@ARGV > 0) { > $acronym = shift(@ARGV); > for ($i=0 ; $i < $count ; $i++) { > run($acronym); > } > } > sub load { > my $words_file = "/usr/dict/words"; > my @words = (); > open WORDS, "<$words_file" or die "can't open $words_file: $!"; > while(my $line = <WORDS>) > { > chomp $line; > $line = lc $line; > push @words, $line; > } > close WORDS or die "can't close $words_file: $!"; > my ($word, $letter); > while(@words) { > $word = shift(@words); > $letter = lc(substr($word, 0, 1)); > push( @{$keyed_words{$letter}}, $word ); > } > } > sub run > { > my $acronym = shift; > $acronym = lc $acronym; > my @letters = split //, $acronym; > print uc $acronym, " = "; > while (my $letter = shift @letters) > { > next if $letter !~ m/[a-z]/; > my @match_words = @{$keyed_words{$letter}}; > my $word = @match_words[rand(@match_words)]; > print ucfirst $word, " "; > } > print "\n"; > } > --- end code ---
Nope, no geeks on ARK. No siree Bob. --oTTo--
On Thu, 31 May 2007 13:08:39 -0400, "Otto Bahn" <e @eio.com> wrote: >"Adam Funk" <a24 @ducksburg.com> wrote >> > OOOPS! SORRY! >> > -----begin deacronymiser.pl--------------------- >> I hope Beable doesn't mind, but I've modified the program so it will >> load the dictionary and split it up once, then process more than one >> acronym in the same command, with an option to generate multiple >> expansions per acronym, without reloading or resegmenting the >> dictionary. >> --- begin example --- >> $ deacronymiser.pl -n 3 ark perl >> ARK = Ablution's Recipe Kiloton's >> ARK = Aplenty Radiogram Kooking >> ARK = Announcer's Rejoinder Kazoo >> PERL = Pygmies Eve's Romano's Loped >> PERL = Philanderer Enhance Rusting Loader >> PERL = Pudgy Enthusiasm Reps Lifeworks >> --- end example --- >> --- begin code --- >> #!/usr/bin/perl >> use strict; >> use warnings; >> use Getopt::Std ; >> my (%option, $i, $acronym); >> getopts("n:", \%option) ; >> my $count = $option{n} || 1; >> my %keyed_words = (); >> load(); >> while (@ARGV > 0) { >> $acronym = shift(@ARGV); >> for ($i=0 ; $i < $count ; $i++) { >> run($acronym); >> } >> } >> sub load { >> my $words_file = "/usr/dict/words"; >> my @words = (); >> open WORDS, "<$words_file" or die "can't open $words_file: $!"; >> while(my $line = <WORDS>) >> { >> chomp $line; >> $line = lc $line; >> push @words, $line; >> } >> close WORDS or die "can't close $words_file: $!"; >> my ($word, $letter); >> while(@words) { >> $word = shift(@words); >> $letter = lc(substr($word, 0, 1)); >> push( @{$keyed_words{$letter}}, $word ); >> } >> } >> sub run >> { >> my $acronym = shift; >> $acronym = lc $acronym; >> my @letters = split //, $acronym; >> print uc $acronym, " = "; >> while (my $letter = shift @letters) >> { >> next if $letter !~ m/[a-z]/; >> my @match_words = @{$keyed_words{$letter}}; >> my $word = @match_words[rand(@match_words)]; >> print ucfirst $word, " "; >> } >> print "\n"; >> } >> --- end code --- >Nope, no geeks on ARK. No siree Bob.
Yay, you proved that the person who said there are no geeks on ARK was wrong wrong wrongety wrong! Nobody said that, of course. But just in case anyone ever does, Goggle will have archived your valuable proof to the contrary. BW
<barb@bookpro.com> wrote > >Nope, no geeks on ARK. No siree Bob. > Yay, you proved that the person who said there are no geeks on ARK was > wrong wrong wrongety wrong!
And, of course, Adam totally misjudged his audience just like I did. Either that or you are unobservant. --oTTo--
On 2007-05-31, barb @bookpro.com wrote: >>Nope, no geeks on ARK. No siree Bob. > Yay, you proved that the person who said there are no geeks on ARK was > wrong wrong wrongety wrong! > Nobody said that, of course.
Well I sure as heck never claimed that! > But just in case anyone ever does, Goggle will have archived your > valuable proof to the contrary.
QED!!!1! -- Is there any proof that English borrows words?? I mean, have we ever given one back? Do we pay for a replacement if we break one? How does this work? [Matthew L Martin, ark]
|
 |
 |
 |
 |
|