#!/usr/local/bin/perl -w # FOGGY text generator # Coded by Eli Bendersky, March 2003 # # Where did it come from ? # ~~~~~~~~~~~~~~~~~~~~~~~~ # # I ran into a C implementation of FOGGY on the web, which # was unfortunately buggy. It seemed like a cool idea, so I # coded this Perl implementation. # According to web sources, FOGGY was first released by # John Lawler, though by a FAQ on his page it seems that it # came from a student of his. Anyway, to find his page, google # for "lawler foggy faq" # # How it works # ~~~~~~~~~~~~ # # There are four sets of phrases: # Initiating phrases (leadin), Subject phrases (subject), # Verbal phrases (verb), Terminating phrases (object) # # Foggy simply selects one of each, at (pseudo) random, # and then strings them together into a sentence. Five # sentences make a paragraph. All phrases are picked # in order not to be meaningful and tie well with other # phrases. # use strict; use POSIX; my @leadin = ("In particular,", "On the other hand,", "However,", "Similarly,", "As a resultant implication,", "In this regard,", "Based on integral subsystem considerations,", "For example,", "Thus,", "In respect to specific goals,", "Interestingly enough,", "Without going into the technical details,", "Of course,", "To approach true user-friendliness,", "In theory,", "It is assumed that", "Conversely,", "We can see, in retrospect,", "It is further assumed that", "Further,", "Clearly,", "Note that", "For one thing,", "Presumably,", "With this clarification,", "Nevertheless,", "In summary,", "It should be noted that", "To further describe and annotate,", "Specifically,"); my @subject = ("a large portion of interface coordination communication", "a constant flow of effective communication", "the characterization of specific criteria", "initiation of critical subsystem development", "the fully integrated test program", "the product configuration baseline", "any associated supporting element", "the systematic use of complex symbols", "the theory of syntactic features developed earlier", "the incorporation of additional mission constraints", "the independent functional principle", "the interrelation of system and/or subsystem technologies", "the product assurance architecture"); my @verb = ("must utilize and be functionally interwoven with", "maximizes the probability of project success, yet minimizes cost and time required for", "adds explicit performance limits to", "necessitates that urgent consideration be applied to", "requires considerable systems analysis and trade-off studies to arrive at", "is further compounded when taking into account", "presents extremely interesting challenges to", "recognizes other systems' importance and the necessity for", "affects a significant implementation of", "adds overriding performance constraints to", "mandates staff-meeting-level attention to", "delimits", "is not subject to", "is functionally equivalent and parallel to"); my @object = ("the sophisticated hardware.", "the advanced software.", "the anticipated fourth-generation equipment.", "the subsystem compatibility testing.", "the structural design, based on system engineering concepts.", "the preliminary qualification limit.", "the evolution of specifications over a given time period.", "the philosophy of commonality and standardization.", "the greater fight-worthiness concept.", "any discrete configuration mode.", "the management-by-contention principle.", "the total system rationale.", "possible bidirectional logical relationship approaches.", "the postulated use of dialog management technology.", "the overall negative profitability."); # Called w/o or with too many arguments ? Print help # ($#ARGV == 0) or die "\n FOGGY is an interactive productivity tool designed to " . "\n assist in the composition of monthly reports, project plans, " . "\n memos to management and so forth. " . "\n Enter the number of sentences needed as a parameter. For example, " . "\n entering 'FOGGY 5' outputs half a screen of heat-treated, battle-" . "\n hard, industrial-strength slop, well suited to choking hogs and " . "\n assurance planners. \n\n"; # How many sententes are needed ? # my $times = shift; # Algorithm: # # For each sentence, pick a leadin, subject, verb and object # Refrain from picking the same component in two consecutive sentences # by remembering the last component picked # my ($leadnum, $lastlead, $subnum, $lastsub, $verbnum, $lastverb, $objnum, $lastobj); $lastlead = $leadnum = $subnum = $lastsub = 0; $verbnum = $lastverb = $objnum = $lastobj = 0; # Print $times sentences # for (my $i = 0; $i < $times; ++$i) { $leadnum = my_random($#leadin) while ($leadnum == $lastlead); $subnum = my_random($#subject) while ($subnum == $lastsub); $verbnum = my_random($#verb) while ($verbnum == $lastverb); $objnum = my_random($#object) while ($objnum == $lastobj); print $leadin[$leadnum] . " " . $subject[$subnum] . " " . $verb[$verbnum] . " " . $object[$objnum] . " "; $lastlead = $leadnum; $lastsub = $subnum; $lastverb = $verbnum; $lastobj = $objnum; # A new paragraph each 5 sentences # (print "\n") if ($i % 5 == 4); } ################################################################ # # Subroutines # # Given an argument N, returns a uniformly distributed # pseudorandom integer between 0 and N (inclusive !) # sub my_random { my $N = shift; return floor(($N + 1) * rand); }