#!/usr/bin/perl my $in = substr(<>, 1, -1); my @in = split(/, /, $in); my @out = (); foreach $word (@in) { my ($root, $tags) = ($word =~ m!"(.*)/(.*)"!); if (!$root) # no tags given { push @out, substr($word, 1, -1); # strip quotes off it next; } my $s = $root; # start a string of all forms of this word my $roo = substr($root, 0, -1); # root minus its last letter for ($tags) { /A/ && do { $s .= ", re${root}"; }; # cover -> recover /D/ && do { if ($root =~ /e$/i) { $s .= ", ${root}d"; # create -> created } elsif ($root =~ /[^aeiou]y$/i) { $s .= ", ${roo}ied"; # imply -> implied } else { $s .= ", ${root}ed"; # cross -> crossed } }; /G/ && do { if ($root =~ /e$/i) { $s .= ", ${roo}ing"; # file -> filing } else { $s .= ", ${root}ing"; # cross -> crossing } }; /H/ && do { if ($root =~ /y$/i) { $s .= ", ${roo}ieth"; # twenty -> twentieth } else { $s .= ", ${root}th"; # hundred -> hundredth } }; /I/ && do { $s .= ", in${root}"; }; # firm -> infirm /J/ && do { if ( $root =~ /e$/i ) { $s .= ", ${roo}ings"; # file -> filings } else { $s .= ", ${root}ings"; # cross -> crossings } }; /M/ && do { $s .= ", ${root}'s"; }; # dog -> dog's /N/ && do { if ( $root =~ /e$/i ) { $s .= ", ${roo}ion"; # create -> creation } elsif ( $root =~ /y$/i ) { $s .= ", ${roo}ication"; # multiply -> multiplication } else { $s .= ", ${root}en"; # fall -> fallen } }; /P/ && do { if ( $root =~ /[^aeiou]y$/i ) { $s .= ", ${roo}iness"; # cloudy -> cloudiness } else { $s .= ", ${root}ness"; # gray -> grayness } }; /R/ && do { if ( $root =~ /e$/i ) { $s .= ", ${root}r"; # skate -> skater } elsif ( $root =~ /[^aeiou]y$/i ) { $s .= ", ${roo}ier"; # multiply -> multiplier } else { $s .= ", ${root}er"; # build -> builder } }; /S/ && do { if ( $root =~ /[^aeiou]y$/i ) { $s .= +", ${roo}ies"; # imply -> implies } elsif ( $root =~ /[sxzh]$/i ) { $s .= ", ${root}es"; # fix -> fixes } else { $s .= ", ${root}s"; # bat -> bats } }; /T/ && do { if ( $root =~ /e$/i ) { $s .= ", ${root}st"; # late -> latest } elsif ( $root =~ /[^aeiou]y$/i ) { $s .= ", ${roo}iest"; # dirty -> dirtiest } else { $s .= ", ${root}est"; # small -> smallest } }; /U/ && do { $s .= ", un${root}"; }; # able -> unable /V/ && do { if ( $root =~ /e$/i ) { $s .= ", ${roo}ive"; # create -> creative } else { $s .= ", ${root}ive"; # prevent -> preventive } }; /X/ && do { if ( $root =~ /e$/i ) { $s .= ", ${roo}ions"; # create -> creations } elsif ( $root =~ /y$/i ) { $s .= ", ${roo}ications"; # multiply -> multiplications } else { $s .= ", ${root}ens"; # weak -> weakens } }; /Y/ && do { $s .= ", ${root}ly"; }; # quick -> quickly /Z/ && do { if ( $root =~ /e$/i ) { $s .= ", ${root}rs"; # skate -> skaters } elsif ( $root =~ /[^aeiou]y$/i ) { $s .= ", ${roo}iers"; # multiply -> multipliers } else { $s .= ", ${root}ers"; # build -> builders } }; } push @out, $s; } foreach $wordgroup (sort @out) { print "$wordgroup\n"; }