Poetic Formulation

Devising a new poetic form was an unusual challenge in Python. If I were to do this assignment without a computer, I think I would have created a form that requires meter. Meter is rather difficult to generate with an algorithm, since the syllabic content of words can vary greatly. At very least, it would take a long time to assemble all the rules. I decided to work with character length instead.

I was thinking about haiku a little bit–I like the idea of communicating a lot in a very minimalist form. Initially I wanted to pull out words of lengths 1-8, and arrange them into a poem of the format
1 3 5
2 4 6
7 8
I put the seven- and eight-letter words together at the end as a couplet, like the last two lines of a Shakespearean sonnet.

Something about the one-letter word just never looked right in the resulting poems, so I got rid of it, and replaced it with a nine-letter word. My new poetic form became:
3 5 9
2 4 6
7 8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Kim Ash
#charlen.py
#uses regex to find words of char lengths 1-9
#creates poem of format 3 5 9 / 2 4 6 / 7 8
 
import sys
import random
import re
 
#list of 9 empty lists, one for each length
words_by_len = [ [], [], [], [], [], [], [], [], [] ]
 
#list for words that will be in poem
poem_words = list()
 
for line in sys.stdin:
  line = line.strip()
  for i in range(len(words_by_len)):
    #find words of each length (i+1 because range() starts at 0)
    regexp = r"\b\w{" + str(i+1) + r"}\b"
    for match in re.findall(regexp, line):
      words_by_len[i].append(match)
 
#randomly select words for use in poem      
for i in range(len(words_by_len)):
	poem_words.append(random.choice(words_by_len[i]))
 
print poem_words[2] + " " + poem_words[4] + " " + poem_words[8]
print poem_words[1] + " " + poem_words[3] + " " + poem_words[5]
print poem_words[6] + " " + poem_words[7]

The first set of poems were generated from the text of Bram Stoker’s “Dracula.” I had to appease the macabre little goth inside my heart–she knows where to find the best words. This one is probably the best:

the ready repulsion
of stay harked
special presence

I really like this one too, especially since it can be read as either triumphant or disheartening:

you brave something
to fast fright
another finished

I want to read this one with a two-syllable “lash-ed” for some reason:

and noble September
he went lashed
Between puncture

The second set of poems were generated from the text of Thomas Hardy’s “Tess of the D’Urbervilles,” a book I despised reading in high school. Everything about it made me angry–the cruelty of society, the stupidity of the characters’ behavior, and the horrible ending. After our class discussions about new ways to read a text, I thought that maybe if I sent “Tess” through my program, I might actually find a way to like it. It took a frustrating number of tries (Hardy is a bit too fond of prepositions), but I finally found a few good ones. This one is really sexy:

her boots sorrowful
to push upward
passion dairyman

I’m not sure what this one means, but I love the imagery:

her hours breathing
is that seemed
vehicle muslined

This one gives an almost perfect summary of the entire novel:

had hands dignities
on milk pretty
brought struggle