Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

69 lines (47 sloc) 1.902 kB

Poetry Parser

Jamie Ly and Nicholas McAvoy

Introduction

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

Downloading libraries

Run the following command:

make dictionary

Building

make clean
make

Running main/Usage

./Main < extra/fox.rhyming
./Main < extra/arb.hku

Running Tests

In ghci:

:l PoemClassifier
PoemClassifier.test

:l PoemAnalyzer
PoemAnalyzer.test

Flow of Program

  1. Read poem from STDIN
  2. Separate poem into words, normalize for dictionary lookup
  3. Build dictionary from cmudict.0.7a file
  4. Submit original poem and dictionary to classifier
  5. Process the poem into Word types, containing extended information
  6. Tokenize the Word lists
  7. Parse the tokens using the extended Word information
  8. Apply one of the parsers (rhymingPoem, haiku, limerick, sonnet) to classify the poem type
  9. Retrieve a RhymeMap to characterize the rhyming scheme of the poem

Main Components Description

  1. Read Main.hs. It reads in a dictionary file from a hardcoded location, and a poem from STDIN
  2. Next, PoemClassifier.hs determines the type of poem. It calls other modules.
  3. CMUPronouncingDictionary provides functions for manipulating the dictionary and turning it into a datastructure to search.
  4. PoemAnalyzer uses the CMUPronouncingDictionary to turn strings into Word types.
  5. PoemParser.hs contains the parsing Monad which determines a poem by parsing lists of Words.
Jump to Line
Something went wrong with that request. Please try again.