Coleridge Bot

Update Aug 1, 2014: The Coleridge Bot is now on Twitter.

In her 1855 autobiography, Harriet Martineau recounts a meeting with Samuel Taylor Coleridge near the end of his life:

I am glad to have seen his weird face, and heard his dreamy voice; and my notion of possession, prophecy,—of involuntary speech from involuntary brain action, has been clearer since. Taking the facts of his life together with his utterance, I believe the philosophy and moralising of Coleridge to be much like the action of Babbage’s machine; and his utterance to be about equal in wonder to the numerical results given out by the mechanician’s instrument. Some may think that the philosophical and theological expression has more beauty than the numerical, and some may not: but all will agree that the latter issues from sound premises, while few will venture to say that the other has any reliable basis at all.

As a way of teasing out some of the implications of seeing a poet as a machine, I decided to take Martineau’s comparison to its limit and create a Coleridge Bot. Based on statistical patterns in Coleridge’s (or another poet’s) work, this program automatically generates rhyming verse from which, perhaps, we might be able to divine some prophetic meaning.

How does it work? This program uses a modified version of the Markov chain method, in which words are randomly generated based on the frequencies of different word sequences in a source corpus. The difference is that the choices are constrained by meter and rhyme, as determined by the CMU Pronouncing Dictionary. The program normally looks at the last two words in determining probabilities, but sometimes this will not produce a word that fits. In which cases it tries looking at just the last word, and failing that picks a suitable word at random.

The source code for this program is on GitHub.