#!/usr/bin/perl # # eebot.pl - a generator of bad ginsberg # # all code original Dave Nelson # the Dave of daves... # # Released to public domain January, 1998 srand( time() ^ ($$ + ($$ << 15)) ); #opens the four major wordlists: nons.poe should contain singluar nouns/noun phrases. #verbs.poe should contain verbs and any necessary prepositions. #adjs.poe should contain adjectives that can easily become adverbs (by adding "-ly".) #place.poe is for the opening line setting establishment; they should all be places, more or less. #poems.txt is an output file, so the eebot can save all of its compositions. open (OUT, ">>poems.txt"); open (VERBS, "verbs.poe"); open (NOUNS, "nouns.poe"); open (ADJS, "adjs.poe"); open (PLACE, "place.poe"); @verbs = ; @nouns = ; @adjs = ; @place = ; chop (@verbs); chop (@nouns); chop (@adjs); chop (@place); &assign; @header = (1..4); #usually 1..4 $head = $header[rand(@header)]; if ($head =~ 1) { $_ = (rand(@adjs))*10000000; s/\..+//g; s/\d{1,3}(\d\d?).+/\1/g; $_ = $_+1; $title = "#$_"; }elsif ($head =~ 2){ $title = "$a $n"; }elsif ($head =~ 3){ $_ = (rand(@adjs))*10000000; s/\..+//g; s/\d{1,3}(\d\d?).+/\1/g; $_ = $_+1; $title = "$n #$_"; }else{ $title = $nplural; }; $title =~ tr/a-z/A-Z/; print OUT "*** $title ***\n"; print "*** $title ***\n"; $topic = $n; $topicplural = $topic; if ($topic =~ /[^aeiou]+y$/){ $topicplural =~ s/([^aeiou]+)y(\b)/\1ies\2/g; }else{ $topicplural = "$topic"."s"; }; $print = "$topic $prepo $p\n"; print OUT "$print"; print "$print"; @lines = (1..2); #usually 1..4 $li = $lines[rand(@lines)]; while ($z <= $li) { # main loop starts HERE $wordcheat = $primewords[rand(@primewords)]; open (WORDS, "$wordcheat.poe"); @words = ; chop (@words); &assign; @choose = (1..7); #usually 1..7 $choice = $choose[rand(@choose)]; if ($choice=~ 7) { $phrase= "$np\n"; &assign; $print="$phrase"."$ad $vgerund\n$gart $nplural\n"; }elsif ($choice=~ 6) { $v =~ s/(\w+)\s?.*/\1/g; $print= "$nplural $v\n "; }elsif ($choice =~ 5){ $v =~ s/(\w+)\s?.*/\1/g; $print = "to $v\n"; }elsif ($choice =~ 4){ $print = "$n $v_3rd_sing\n$vprep $gart $nplural\n"; }elsif ($choice =~ 3){ $phrase= "$gart $nplural\n"; &assign; $print="$phrase"."$vp\n"; }elsif ($choice =~ 2){ #$topicplural= $topic; #$topicplural =~ s/([^aeiou]+)y(\b)/\1ie\2/g if $topic =~ /[^aeiou]+y\b/; $print = "$topicplural $v\n$nart $n\n"; }else{ $print= "$w\n"; }; print OUT "$print"; print "$print"; $z++; }; &assign; @closing = (1..3); $choice2 = $closing[rand(@closing)]; if ($choice2 =~ 1) { #$topicplural = $topic; #$topicplural =~ s/([^aeiou]+)y(\b)/\1ies\2/g if $topic =~ /[^aeiou]+y\b/; $print= "$vgerund $topicplural\n"; }elsif ($choice2=~ 2) { $v =~ s/(\w+)\s?.*/\1/g; #$topicplural = $topic; #$topicplural =~ s/([^aeiou]+)y(\b)/\1ie\2/g if $topic =~ /[^aeiou]+y\b/; $print= "$topicplural $ad $v\n"; }else{ $print= "$a $topic \n"; }; print OUT "$print"; print "$print"; print OUT " -EE Bo”t\n\n "; print " -EE Bo”t\n\n"; sub gerund{ #this sub-routine makes $v into a gerund. local($one); local($two); $_ = $v; /(\w+)(\W.*)?/; $one = $1; $two = $2; if ($1 =~ /\b[^aeiou]{1,2}[aeiou][^aeiouy]\b/){ $one =~ s/\b(.*)(.)\b/\1\2\2/g; }elsif ($1 =~ /[^aeiouy]+e\b/) { chop($one); }; $vgerund = "$one"."ing"."$two"; }; sub adverb { #makes $a into an adverb. local($adjective); $adjective = $a; if ($adjective =~ /\b.+ble\b/){ chop($adjective); chop($adjective); }elsif ($adjective =~ /\b.+y\b/){ chop($adjective); $adjective = "$adjective"."i"; }elsif ($adjective =~ /\b.+ce\b/){ chop($adjective); $adjective = "$adjective"."i"; }elsif ($adjective =~ /\b.+ic\b/){ $adjective = "$adjective"."al"; }; $ad = "$adjective"."ly"; }; sub assign { #assigns all of the variables. @verb_phrases = ("$v\n$art $a $n","$ad $v\n$nplural"."' $n"); @noun_phrases = ("$nart $n","$a $n","the $a $n $prepo\n the $topic"); @prep = ("in","near","under","of"); @primewords = ("nouns","adjs"); #verbs @articles = ("a","the","your","this","that","our","some"); @plural = ("your","the", "their", "these","those", "our","some"); $prepo = $prep[rand(@prep)]; $nplural = "$nouns[rand(@nouns)]"."s"; $nplural =~ s/([^aeiou]+)ys(\b)/\1ies\2/g if $nplural =~ /[^aeiou]+ys\b/; $w = $words[rand(@words)]; $v = $verbs[rand(@verbs)]; $n = $nouns[rand(@nouns)]; $a = $adjs[rand(@adjs)]; $gart = $plural[rand(@plural)]; $p = $place[rand(@place)]; $e=""; $np = $noun_phrases[rand(@noun_phrases)]; $vp = $verb_phrases[rand(@verb_phrases)]; &adverb; &gerund; &verb_3rd_singular; if($n =~ /\b[aeiou].+\b/){ $nart="an"; }else{ $nart=$articles[rand(@articles)]; }; if ($a =~ /\b[aeiou].+/){ $art="an"; }else{ $art=$articles[rand(@articles)]; }; }; sub verb_3rd_singular { #converts $v into third person singular form of verb. $v =~ s/(\w+)\W?(.*)?/\1/g; $vprep =$2; $e="e" if $v =~ /go|ss$/; $v_3rd_sing = "$v$e"."s"; };