Classics, code

Interlude: Rewriting My VergilBot with Owls


In the last month I’ve been a little distracted from my Ovid project, because I realized my Vergilbot was going to finish tweeting the Aeneid on Sunday, June 4 and I figured I should do something interesting with it after it finished.

So, I’d had this idea for a while that I wanted to use the sortes URL from the Aeneid API. The sortes is basically like a random command, in that it grabs a random line of the Aeneid. The name comes from the Sortes Vergilianae, an ancient form of fortune telling that (I am not making this up) flipped to a random page of the Aeneid to answer a question. In all fairness, this seems no worse a method than reading modern astrology columns, which is why I thought it would be fun to play with.

Someone had sensibly built a straight-up sortes bot, LotsByVergil, so I knew that wasn’t needed. And for a while I’d had a notion that the Aeneid would be more fun with more owls. So I took this as an opportunity to rewrite the Vergilbot in Python.

(I still love Node, by the way, but if you’re getting into natural language processing, Python makes the most sense. Once I got familiar with the NLTK (natural language toolkit), it was delightfully easy to do things like find parts of speech etc.)

The nuts and bolts of the bot are pretty simple: it grabs a line from the url, in English; finds the first noun; replaces that noun it with the word owl; and tweets the result like so:

I’ve renamed the bot’s title to YourDailyOwl, but I didn’t change the handle (YourDailyVergil) because it’s still Vergil.

I’d really like to make the bot tweet owls in Latin, and I’ll be able to do that once I get the CLTK (classical language toolkit) files to upload to Heroku — the NLTK is already packaged up nicely and isn’t much trouble, but the CLTK isn’t automagic yet.

And of course after that I’d like to get back to my Ovid project.

I was sad to shut down the AWS instance of the original bot, though not sad to stop maintaining it. I’d tried using AWS’s pre-built Node images and they kept failing — part of why it took so long for the bot to finish — and I eventually just went back to installing Node myself. (And yes, I know, Docker blah blah blah but I’m kind of trying to avoid all of that now that I don’t deploy software for a living.)

Anyway, the new owlbot’s code lives here, and the old bot is still on Github too.