The making of a bot

I made a twitter bot – an engine which tweets automatically generated lists, ideally in the style of the Makura no Soshi (the Pillow Book).

I have a long informal history of programming, back to the days of BASIC, but I’ve not done any for probably a decade and much of the newer styles of programming are completely alien to me (e.g. calling other routines from the internet, pretty much everything to do with the internet). I found even the introductory material on things like Node.js assumed some knowledge I didn’t have, but with the bit of help from some youtube videos and the various tutorials on twitter projects I managed to get up and running and then cobble together some code. I’m not confident that it’s error-free and I am confident that it’s not as efficient as it could be, but it seems to work.

The bot uses a nearley grammar – a set of rules that randomly generates text of a certain style/pattern. The inspiration for the bot was the Midsomer Murders Plot Bot (and the coder of that was super helpful in pointing me in the direction of how to get started), although I am pretty sure it uses a different engine to generate its text.

The lists the bot generates are supposed to be in the style of the Makura no Soshi, a Japanese classic by the tenth century lady in waiting, Sei Shonagon. That books is one of the greats of world literature, in my opinion, a miscellany of different anecdotes, poetry, and lists. The Heian court was a very different world to ours, and so for a text to reach across the vast expanse of time and be able to communicate something of the society which gave birth to it, to be alternately funny, touching, beautiful, is quite something. It’s a light read, and yet a great one. Everyone should read it.

The lists, specifically, are categories of like objects – shameful things, amusing things, things that seem far but are near, and so on. The bot is intended to generate random lists in this style. Sometimes they work, sometimes not so much (and the seasons section of the grammar needs a serious overhaul at the moment); the idea is less to generate accurate lists than it is to see the harmonies and contrasts that emerge by chance. There’s more coding to be done (I want to add some different structures in the interests of variability, and tidy up some of the rougher edges) but the proof of concept is there, and some of the lists already make me laugh.

Here’s the code on GitHub:

EDIT: here’s an episode on the Pillow Book from the Japan History Podcast:





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s