poem
Class GrammarPhrases

java.lang.Object
  |
  +--poem.GrammarPhrases

public class GrammarPhrases
extends Object

An object of this class contains all the methods to construct phrase structure rules.

This class contains the method (getNP) that needs modifying to complete the project.

Each phrase structure rule method constructs the phrase requested by combining words of the right category, syllable length, and, if required, rhyming key. Currently, noun and verb phrases are fully supported. Prepositional phrases are supported but wont work until modifications to getNP() occur. Prepositions make prepostional phrases with the noun phrase following them.

Here is a list of prepositional phrases, a preposition (underlined), followed by a noun phrase:

To complete the project, you need to modify getNP() so that it returns the noun phrase needed to complete the prepositional phrase.


Field Summary
(package private)  Lexicon lexicon
          This is the obect that contains, and controls, the words used in generating haikus.
 
Constructor Summary
(package private) GrammarPhrases()
          The default constructor: initializes lexicon.
 
Method Summary
 String getNP(int syllables)
          Returns a noun phrase with the same number of syllables as indicated in the parameter.
 String getNP(int syllables, int rhymingKey, int catKey)
          Returns a noun phrase with the same number of syllables as indicated in the parameter and the rhymingKey matched to the second adjective.
 String getPP(int syllables, int rhymingKey, int catKey)
          Will return a prepositional phrase made up of a preposition and a noun phrase, once the method getNP has been modified.
 String getVP(int syllables, int rhymingKey)
          Returns a verb phrase made up of one verb - with the same number of syllables and rhyming key as the parameters.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

lexicon

Lexicon lexicon
This is the obect that contains, and controls, the words used in generating haikus. When a grammar phrase is needed, the correct category of word is requested from lexicon.
Constructor Detail

GrammarPhrases

GrammarPhrases()
The default constructor: initializes lexicon.
Method Detail

getNP

public String getNP(int syllables)
Returns a noun phrase with the same number of syllables as indicated in the parameter. This noun phrase only gets nouns with the rhyming key NONE. Two "if" statements are used, one construction occurs when syllables equals three: determiner + 2 syllable noun, the other when syllables equals four: determiner + 1 syllable adjective + 2 syllable noun. The "if" statements check if the parameter syllables equals three or four:
Parameters:
syllables - The total number of syllables in the created noun phrase.

getNP

public String getNP(int syllables,
                    int rhymingKey,
                    int catKey)
Returns a noun phrase with the same number of syllables as indicated in the parameter and the rhymingKey matched to the second adjective. One "if" statement is used: If this equality holds, a noun phrase is constructed as follows: 1 syllable adjective + 2 syllable adjective (matching rhymingKey) + 2 syllable noun. Currently, this method assumes all noun phrases requested will be of 5 syllables long. To construct the noun phrase needed by the prepositional phrase, another "if" statement will need to be added. There exists in Rhyme a category key called NOUN that can be used as a parameter in place of ADJ. The trick is deciding where you want the rhyme to be placed when constructing a prepositional phrase.
Parameters:
syllables - The total number of syllables in the created noun phrase.
rhymingKey - The rhyming key that will rhyme with a word in the phrase.
catKey - The key to determine the category of the word carrying the rhyme.

getVP

public String getVP(int syllables,
                    int rhymingKey)
Returns a verb phrase made up of one verb - with the same number of syllables and rhyming key as the parameters.
Parameters:
syllables - The total number of syllables in the created verb phrase.
rhymingKey - The key that rhymes with the verb.

getPP

public String getPP(int syllables,
                    int rhymingKey,
                    int catKey)
Will return a prepositional phrase made up of a preposition and a noun phrase, once the method getNP has been modified. Currently, it gets a 2 syllable preposition that rhymes with the parameter rhymingKey, and joins this with a noun phrase. The noun phrase is obtained through a call to getNP:

getNP(5, rhymingKey, catKey); To get this method working, getNP() needs to be modified so that it will return a noun phrase that will work with a preposition to form a seven syllable line of haiku.