Poetry generator

From dandi08

Jump to: navigation, search

A poetry generator would be a program that algorithmically creates poetry. There are three basic levels that could be implemented. In order of "basic-ness," they are:

  • prosodic form
  • syntax
  • semantic value

Contents

[edit] Levels of the Poem

[edit] Prosodic Form

This includes meter and rhyme. An example of a poem (specifically a limerick) with a prosodic form, but with no syntax would be:
ELOISE WERE DARRELLE GUARDIOLA
DAHRAIN MARTURANO CACCIOLA
SURESH LUNATI
ABAD LUNATI
CASSELLA OMANI STAVOLA

[edit] Some Specific Examples of Prosodic Forms

[edit] Syntax

An example of a syntactically valid sentence without much semantic value would be, "Colorless green ideas sleep furiously." Note that the verbal grammar for poetry often varies from "normal" spoken grammar:

"Linux" haiku by Ian Ruotsala:

yurt-dwelling hackers
free software in your mindspace
revolt against Bill

This would sound very unusual if spoken in a conversation. Nevertheless, it still "shadows" spoken grammar. E.g., it would sound very strange to have a line like:

mindspace your software in free

[edit] Semantics

The actual meaning. This feature is probably the hardest of the three levels to implement on a software poet.

[edit] Implementation details

[edit] Goal?

It is helpful to have a concrete goal for a project; something like "program a software poet" is somewhat vague. Here are possible goals, primary, secondary, etc:

[edit] Get One of the Poems Published

If the software poet ends up making human-enough writings, perhaps an attempt could be made to publish some of the poems. The publisher would not be told that a computer wrote them, and a pseudonym would be thought up.

[edit] Distribute the Software Poet

E.g., the software poet could be turned into a Facebook application; "Put a random limerick on my profile". If this were to be done, the issue of intellectual property would have to be considered, even if there are no plans to make money off of it.

[edit] General Form vs. Specific Form

Probably the easiest way to implement a software poet would be to pick a specific prosodic form (e.g. limericks), and write code from that basis. However, in programming, it is considered better style to program for the general case. This is a question to consider for this project. Should this project work just for, e.g., limericks? Or, should we extend it, such that, given proper instructions, it could also program sonnets and haiku?

[edit] (Very Preliminary) Program structure

[edit] Class Main

Will control the program flow.

  1. input: contingent on UI
  2. WHILE poem is NOT complete:
    1. get WORD from verbal grammar
    2. does WORD fit meter and rhyme?
    3. yes: add WORD to poem.
    4. no: replace WORD with new word from verbal grammar. Retest.
  3. output: String for poem

[edit] Class Grammarian

This class would apply the verbal grammar, selecting words at total (pseudo)randomness, or potentially a randomness "weighted" by semantic values. It would ask the Poem class whether the new word fits into the poem's meter and rhyme. If so, it would go onto the next word in the sentence. If not, it would try a new random word (we'd have to track which words we had already selected). If it totally cannot find a word of that type, it would do the recursive backtracking thing. Since recursive backtracking is a computationally intensive algorithm, hopefully either:

  1. it will realize very quickly that there is no solution (e.g., if there were only three options, such as for articles)
  2. it would not have to search through the entire corpus of, e.g., nouns, since it would probably find a suitable noun in the thousands that are presented.

[edit] Class Poem

Will represent the poem.

  • Fields: to do
  • Functions:
    • fitsMeter(word_dict):
      • pre: word_dict is a dictionary, with the "spelling" word mapping onto a phonetic spelling
      • post: returns Boolean, True if word fits into the poem's meter, False otherwise
    • fitsRhyme(word_dict)
      • pre: word_list is a dictionary, with the "spelling" word mapping onto a phonetic spelling
      • post: returns Boolean, True if word fits into the poem's rhyme, False otherwise
    • appendWord(word_string)
      • pre: word_string is a string
      • post: word_string is appended to poem
    • removeWord()
      • post: most recent word is removed from poem
    • getLine(line_number)
      • pre: line_number is int, representing line in poem
      • post: return String of line line_number
    • more to come!

[edit] Poem sub-classes

e.g. Class Limerick, Class Sonnett

[edit] User Interface

GUI? Text?

[edit] Potential Members

If you are interested in working on this project, leave your name here (press the "edit" button to your right to add your name):

[edit] Interesting and Relevant Links