Archive for November 14th, 2008

A Chain!

Friday, November 14th, 2008

Via the Shakespeare Geek, we find a website that uses a Markov chain to generate an alternate version of Hamlet. Check it out!

From what I can tell, the site works from a table of which words follow other words in the play, and how often. It then constructs a chain by looking at the last word (or few words) that were entered, and choosing a random word of those that actually follow that word (or few words) in the play.

For example, one place in the play has “Alas! poor Yorick. I knew him, Horatio.” Another part of the play has “I knew your father.” The Markov chain might generate “Alas! poor Yorick. I knew…” and then, only looking at the last two words “I knew” might follow up with “your father.” The final result would be “Alas! poor Yorick. I knew your father.”

This is a favorite example provided by the author, but there are a lot of funny possibilities. You can keep refreshing the page to get a new randomly-generated Hamlet.

Thanks, Rosencrantz and Guildenstern are dead:
Ere I could accuse me of the courtier, cousin, and with a look so piteous in purport
As I perceived it, if I gall him slightly,
Whips out his rapier, cries, ‘A rat, a touch,
The queen desires you to remain
Here is your only jig-maker. What it should be old as I will be laid to us, till I know not–lost all my best obey you, and, at a shot
So art thou to me all the battlements their ordnance fire: proclaim no shame
When Roscius was an actor in Rome,–
As of a dear father murder’d,
With mirth in funeral and with a crafty madness, like the herald Mercury
New-lighted on a roar? Not one now o’er
The triumph of his own scandal.

Enjoy!