To celebrate one of the last days of National Poetry Month as well as The Accidental Developer’s 100th blog post, I will attempt to combine a bit of computer science and poetry.
I’ve been studying grammars and formal languages, among other things, this past semester in my Theory of Computation class. One thing that it reminded me of was the second Javascript application I ever developed (with the help of my friend and college classmate Miranda Tarrow): The Random Goth Lyric Generator.
I took a simple sentence structure (subject, verb, adjective, object) and made random substitutions for each line, 4 lines per stanza, 4 stanzas per poem.
The (slightly less-than-formal) grammar for each line would look something like this:
Line -> SSL | PSL
SSL -> SNP SV A O
PSL -> PNP PV A O
SNP -> Singular Noun | Singular Noun Phrase
PNP -> Plural Noun | Plural Noun Phrase
SV -> Singular Verb
PV -> Plural Verb
A -> Adjective
O -> Object
We could extend this to the entire poem:
Poem -> Stanza Stanza Stanza Stanza
Stanza - > Line Line Line Line
The word list was meant to be dark and foreboding but was often hilarious–the examples included:
Nouns & Noun Phrases:
- My solitude
- Your touch
- A ravenous she-wolf
- Spiders
Verbs & Verb Phrases:
- entangles
- summons
- grovels before
- spews forth
Adjectives:
- labyrinthine
- diseased
- spectral
- infernal
Line -> SSL -> SNP SV A O could become:
Your touch entangles infernal spiders.
I don’t know why the list of objects was a separate list of nouns, as it seems to me now that it could have pulled from the same list. Since the grammar used just one sentence structure, the results were very repetitive but frequently humorous. I often considered expanding the possible sentence structure (something as simple as making the adjective optional), but decided that the repetition was part of the charm. In fact, many poems and song lyrics feature repetition, and the results seemed eerily intentional at times.
The page was very popular for a time. I received quite a bit of e-mail regarding the page, including suggestions for additional words. Someone sent a song they’d recorded for which they used the random lyrics (with the addition of a shouted, “There’s that m———— word again!” in the middle). At least one randomly-generated poem was published in a small poetry journal.
I’ve considered creating a sequel to parody William Carlos Williams and loading it up with words from his own poems:
Poem -> S1 S2 S3 S4
S1 -> Noun Verb newline Preposition
S2 -> Article Adjective Noun newline Noun
S3 -> Adjective Preposition Adjective newline Noun
S4 -> Preposition Article Adjective newline Noun
Which might produce something like:
no one spilled
withthe whole honey
sucklepressed after sweet
odorwhile the urgent
petals
It just doesn’t seem quite as funny or compelling. I can venture a guess that William’s sparse form and carefully selected language doesn’t lend itself to random imitation as well as verbose and self-indulgent free verse. Although perhaps the sample is merely too small!