top of page
  • Writer's pictureSon Luu

Poetic Forms with Python


Class: Reading and Writing Text

Professor: Allison Parish




This week, each of us is going to create a new poetic form and write a computer program that generates texts that conform to the poetic form devised. The poetic form could be something as simple as “Each line must begin with the letter ‘A’” or something as sophisticated as Mac Low’s diastics.


Then we will evaluate our work based on:

  • How well does the output of your computer program conform to our invented poetic form? Could a human do it better?

  • How does the choice of source text (“raw material”) affect the character and quality of the poems that the program generates?


Inspiration

I found a list of "weather conditions" json file developed by Parker Higgins on Darius Kazemi's Github page, and immediately had an idea of making a poetic form and latter a poem related to all these weather conditions.

[https://github.com/dariusk/corpora/blob/master/data/science/weather_conditions.json]


It's kind of a cliche, but I recalled how weather conditions are sometime used as metaphor for humans' moods. Most of the time, such comparison refers to the unexpected fluctuation of one's mood, which is completely subjective. However, I could also think of weather conditions as different personalities and behaviors people portray depending on whom they are with at the moment and whether they feel comfortable around them etc. This is often true in a relationship between two people where they know each other so well, they know the different sides and behaviors of the one another as they spend more time around each other. Oftentimes, they even get influenced by the one another's personalities.


The Poetic Form

I created a simple Illustrative form where a stanza starts with a statement or a conclusion, followed by one to two sentences that illustrate that conclusion. The stanza is separated by new line of space, which allows readers to quickly reflect on each illustration,


Illustrative Form


Statement "A"

Illustration 1 for statement "A".


[space]


Statement "A"

Illustration 2 for statement "A".


[space]


Statement "A"

Illustration 3 for statement "A".


etc.

... The same formula repeats for however many loops required. In this example, I am creating a series of 14 stanzas.


 

Prepare Raw Materials



I first download the json file of weather conditions into my jupiter notebook. I tested to see if the json file works with 'random' function.




 

Create Poetic Form with Tracery Library



Based on the formula I created above. I had to tweaked more than a few times, but finally came up with a program as follow, using Tracery library - a powerful language and toolset for generating text from grammars created by Kate Compton.





The Product


Reflect

⌘ How well does the output of your computer program conform to your invented poetic form? Could a human do it better?


I thought the output was pretty good. I was quite happy with the result. The above outcome was after the first run. It would definitely take me a lot more time to create something like this.


What didn't work but I kind of liked it, was the repetition of the weather conditions in both places in the same sentence "You give me A; I give you back A". I think the fact that the formula didn't take into account this repetition is quite interesting because of the chance of that repetition happening within 14 stanzas per execution of the program.


From the computer generated version, I could even pick out the 14 stanzas I resonate with the most and group them together to create a new unique, another more controlled version of the product.


⌘ How does your choice of source text (your “raw material”) affect the character and quality of the poems that your program generates?


I changed the formula about 3-4 times before this final version. The raw material definitely played an important role in modification process. Plugging it in and seeing how the raw json data fit into the formula gave me more control in predicting how the outcome would be, and was able to adjust accordingly.


bottom of page