Jamie Ly and Nicholas McAvoy
From the advent of spoken language, poetry has been a protocol for sharing human experience. We would like to write a poetry parser and classifier.
The parser will determine if a given string qualifies as any of the following English poetic forms.
Goal forms include (tentative):
- formless rhyming poem (each line ends in a word that rhymes with the last)
- haiku
- limerick
- Shakespearean sonnet
Run the following command:
make dictionary
make clean
make
./Main < extra/fox.rhyming
./Main < extra/arb.hku
In ghci:
:l PoemClassifier
PoemClassifier.test
:l PoemAnalyzer
PoemAnalyzer.test
- Read poem from STDIN
- Separate poem into words, normalize for dictionary lookup
- Build dictionary from
cmudict.0.7a
file - Submit original poem and dictionary to classifier
- Process the poem into
Word
types, containing extended information - Tokenize the
Word
lists - Parse the tokens using the extended
Word
information - Apply one of the parsers (rhymingPoem, haiku, limerick, sonnet) to classify the poem type
- Retrieve a RhymeMap to characterize the rhyming scheme of the poem
- Read
Main.hs
. It reads in a dictionary file from a hardcoded location, and a poem from STDIN - Next,
PoemClassifier.hs
determines the type of poem. It calls other modules. CMUPronouncingDictionary
provides functions for manipulating the dictionary and turning it into a datastructure to search.PoemAnalyzer
uses theCMUPronouncingDictionary
to turn strings into Word types.PoemParser.hs
contains the parsing Monad which determines a poem by parsing lists of Words.