CIT 594 Assignment 2: Random sentence generation
CIT 594, Spring 2007


General idea

Write a text file containing BNF grammar for English sentences. Here is an example you can start with, but you should either write your own, or "improve" this one. In either case, replace the vocabulary items (the "terminals") with your own vocabulary items.

Read in your BNF grammar and use it to generate about twenty random sentences.


Write a main class SentenceGenerator that does the following:

You should have the following classes and their constructors and methods:


You do not need to create a GUI for this program (although you may if you wish). If you do, SentenceGenerator should extend JFrame.

Your BNF rules should be kept in a Map<String, Definitions> in the SentenceGenerator Grammar class.

All non-private elements should have a well-written Javadoc comment. Remember that a Javadoc comment is supposed to tell the user everything s/he needs to know in order to use that element.

It is possible to write the generate method as an iteration rather than as a recursion. Don't! Part of the purpose of this assignment is to get you familiar with recursion.

Generate the Javadoc and look it over before you turn in your program.

Provided code (use this tokenizer when you read in the grammar) and

Due date

Zip up and turn in your complete project, including all test files and the generated Javadoc, via Blackboard, before midnight, Tuesday January 23.