#!/usr/bin/perl use warnings; use strict; use Lingua::EN::Tagger; my %fragments; my $p = new Lingua::EN::Tagger; my @adjectives = qw/nervous nutty obnoxious outrageous panicky repulsive scary selfish sore tense terrible testy thoughtless tired troubled upset uptight weary wicked worried/; my @stems = ( "It's been said that there were many", 'Goldfish spoke with', 'There were three', 'People used to see 42', 'There were quietly-roaming groups of' ); while ( my $line = ) { chomp $line; my $adjective = $adjectives[ int rand $#adjectives + 1 ]; $line = $p->add_tags($line) =~ s//$adjective /gr =~ s/<.+?>//gr; my @words = split / /, $line; for my $i ( 0 .. $#words - 1 ) { push @{ $fragments{ $words[$i] } }, join ' ', @words[ 0 .. $i - 1, $i + 1 .. $#words ]; } } print "Once upon a time...\n\n"; my @sentences; for my $term ( keys %fragments ) { my $stem = $stems[ int rand $#stems + 1 ]; push @sentences, "$stem $term " . ( join ' and ', @{ $fragments{$term} } ) . '.'; } print join ' ', @sentences; print "\n\nThe times have certainly changed.\n\nThe end."; __DATA__ big businesses fast red cars big smart companies fast light planes fast animals big bad wolves small bad girls bad growling bears