Villanelle Bot: Poems in the Villanelle Form, Created Using Random Posts from Twitter

Excited to announce my latest project and Twitter Bot: @VillanelleBot! About once an hour, this bot searches Twitter for random words (generated by the ever-fantastic Wordnik). Then, it sifts through a ton of Twitter posts to find only those that match a certain criteria (namely, to have a particular word at the end of the tweet).

If it’s lucky and finds enough matches, it stitches everything together and creates a full poem, which is then published in full on Tumblr. It then favorites every tweet it uses, and also announces the new poem via the @VillanelleBot account.

For each poem, every line links back to the original poster, and a full list of all the participants is listed in the footer. It’s a group effort, after all.

The villanelle is a really great poetic form, and has a really interesting structure. In the first stanza, the first and third lines rhyme… and are repeated throughout the poem. They alternate, and serve as the final lines for the subsequent stanzas. At the very end of the poem, they come back together and finish the poem as a couplet.

A really great villanelle has a sense of completion to it, a sense that as the poem progresses… it starts to pull together, as the two lines converge.

In making this bot, I had a tremendously fun time looking into the more well-known poems using the form. I delved into several poems, trying to see how many words and characters each line used. On average, most villanelles had about 38 – 52 characters (8 words) per line.

To arrive at the final poem, each post has to go through a gauntlet of filters. It can’t be too short or too long, it can’t have numbers, it can’t contain excessive punctuation, the word has to be at the end of the tweet, etc.

One particularly nice feature I’m proud of happened last week or so, and helped to increase the number of posts that the bot could pull from. Instead of simply looking for words at the end of each tweet (which made the poem a little stiff and robotic), I started searching for words that were within X distance from the end of the tweet.

This made for a longer line, but also allowed me add in a line break, and continue the sentence while still adhering to the poem’s rigid rhyme scheme. Not only did this open up a lot more candidates in terms of viable tweets… it also, in my opinion, makes the poems feel less forced.

I quite like both styles, honestly. If you check out the poems I researched, Thomas, Roethke, and Plath all have a lot of stoppers. In reading, nearly each line ends very definitively, before allowing the reader to progress.

But what I like about Bishop’s villanelle are the moments where the poem cascades along to the next line. While I am a big fan of formal poems, I’m a particular fan of formal poems that do a good job of hiding their structure. Because the rhymes are so constant, it’s a rare villanelle that can make you forget its strictness as you’re reading.

This was a super fun project that I’m still fine-tuning. I’m noticing a few small errors here and there, along with some frequently repeated phrases.

In terms of edits, I’ve tried to keep my interference at a minimum. The few things I do include: capitalizing the first letter of each tweet, adding in a period at the end of each tweet (if none exist), and changing instances of ” i ” to ” I .”

The code works, but boy howdy does it need some serious refactoring. Lots of nested loops that get the job done, but could stand some clean up. With us heading out of town tomorrow, I guess that’ll be a task for the future – as I primarily just wanted to launch the project before we left.

So there you go – automated villanelles, once an hour! Too bad I put all this time towards a project that earns zero money, but hey – it was fun. Although now it has me thinking…

1) Create bot the writes villanelles automatically.
2) Fire team of 1,000 monkeys with 1,000 typewriters.
3) ?????
4) Profit!

I’ll be saving money on paper and typewriter ribbon, so technically I’m already ahead, right?

Outdoor Coding
Love from (and for) Wordnik

This Post Has 2 Comments

  1. Dude, this is so good. Reading through some of these is absolutely FASCINATING!

    Some of these lines would make pretty remarkable rap verses. I keep hearing Quasimoto’s rap voice while reading some of them!

    Chris Reply

    • Thanks! I haven’t had time to read them all, but still noticing certain lines that tend to get picked up, and recur in multiple poems. There are a few small bugs here and there that I’d like to improve, but happy it’s mostly functioning on its own right now.

      One thing I had to disable was the “favorites” functionality. I got the account blocked by Twitter due to this, and though I was able to get it unlocked in short order… it’s gotten me wary of trying to do this. I thought I’d be safe at only favoriting 13 tweets at a time, but I guess not. Shame, as that was the way I could “alert” other users that their tweet had been used in a poem.

      I’m glad to hear others are liking some of the poems. They’re often gibberish, but in a few cases here and there – a poem holds its subject or voice throughout, and comes close to coherent.

      avoision Reply

Leave A Reply