preview

The Last Verse Of A Well-Known Nursery Rhyme Scheme

analytical Essay
403 words
403 words
bookmark

package unit2randomsentences; /* The last verse of a well-known nursery rhyme: This is the farmer sowing his corn That kept the rooster that crowed in the morn That waked the judge all shaven and shorn That married the man all tattered and torn That kissed the maiden all forlorn That milked the cow with the crumpled horn That tossed the dog That worried the cat That chased the rat That ate the cheese That lay in the house that Jack built. Some rules that capture the syntax of this verse: ::= [ and ] ::= this is [ ] the house that Jack built ::= the [ ] that ::= farmer | rooster | judge | man | maiden | cow | dog | cat | cheese ::= kept …show more content…

In this essay, the author

  • Analyzes the last verse of a well-known nursery rhyme: the farmer sowing his corn that kept the rooster that crowed in the morn that married the man all tattered and torn that kissed the maiden all forlorn
  • Describes the rules that capture the syntax of this verse: farmer | rooster | judge | man | maiden | cow | dog
  • Describes how the program implements rules to generate random sentences. the program generates and outputs one random sentence every three seconds.
  • Explains that the script is halted by typing control-c in the terminal window where it is running.
  • Explains that static final string modifiers = "that crowed in the morn", "sowing his corn" and public static void main(string[] args).
  • Explains the catch (interruptedexception e): if (math.random() > 0.2) randomnounphrase(); system.out.print("the house that jack built");

All the verses of the rhyme can be generated, plus a lot of sentences that make no sense (but still follow the syntax). Note that an optional item like [ ] has a chance of being used, depending on the value of some randomly generated number. The program generates and outputs one random sentence every three seconds until it is halted (for example, by typing Control-C in the terminal window where it is running). */ public class SimpleRandomSentences { static final String[] nouns = { "farmer", "rooster", "judge", "man", "maiden", "cow", "dog", "cat", "cheese" }; static final String[] verbs = { "kept", "waked", "married", "milked", "tossed", "chased", "lay in" }; static final String[] modifiers = { "that crowed in the morn", "sowing his corn", "all shaven and shorn", "all forlorn", "with the crumpled horn" }; public static void main(String[] args) { while (true) { randomSentence();

Get Access