Dear Chris,
I wrote:
> || % perl -wMstrict -lne 'use vars qq.%x.; (my $y = $_) =~ s/ss$/s/; \
> || print if $x{$y}; $x{$_}++;' /usr/dict/words
> || ass
> || buss
> || canvass
> || discuss
> || Douglass
> || hiss
> || %
>
> [...]
> The Lingua::EN::Inflect approach would obviously not be quite
> so straightforward.
Actually, I was mistaken. It *is* equally straightforward.
Just stick the plural version of each word into the hash,
too.
|| % perl -MLingua::EN::Inflect=PL -wMstrict -lne 'use vars qq.%x.;
|| my $y; print if ($y = $_) =~ s/ss$/s/ && $x{$y}; \
|| $x{$_}++ if /s$/; $x{PL($_)}++ if PL($_)=~/s$/' /usr/dict/words
|| [...]
|| %
I've also fixed one bug ("print if s///") and added an
optimisation ("$x{...}++ if /s$/").
I have not included the output of the second one-liner in
this email, in case someone is trying to guess the answer
"mentally".
The output is easily verifiable manually, as Chris had suggested.
Aside:
* Hail to CPAN: I installed Lingua::EN::Inflect in minutes.
* Hail to Damian: It worked. :-)
peace, || Byatrayanapura: Better governance thru online taxes:
--{kr.pA} || http://tinyurl.com/296js
--
"If I have not seen farther, it is because giants have stood on my shoulders."
-- V. Guhan. [with apologies to Newton, Sir Isaac.]
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm