Hamlet Generator

What is this?

This is a Markov text generator that uses content in Shakespeare's Hamlet to generate text.

How do I use it?

First, select some or all of the scenes in Hamlet to use as source content. Then, select some characters that you would like to be present in the generated scene. Characters that appear red do not have any lines in the selected scenes. If you would like, you can change the settings in the generation panel. To restore the settings to the default, simply press the reset button next to the generate button.

How does it work?

A Markov chain is a process that provides transitions from one state to another based soley on the current state. In terms of text generation, the state is the previous n words where n is chain length - 1. For example, consider the following example: If we want to take the sentence: "I have a dog and I have a cat." and create a state diagram to use for text generation, we would first decide on the chain length. Say we choose a length of 3. This means each group of words would be 3 words long and the last two words of the current tuple would be used as the state. Now, we would split the sentence into a table that looks like this:

State Prediction
I have a
have a dog
a dog and
dog and I
and I have
I have a
have a cat.

Now, we would pick a starting point. Let's start with I and have. Using the state table, we can see that the only prediction is a with two rows containing this prediction. After adding a, we now have the sentence I have a. However, to continue we will only use the last two words, have and a. This time, there is a 50% chance of choosing dog and a 50% chance of chosing cat. (notice how the punctuation is included). We will choose one of these using a weighted random (1/1 in this case). The chain continues until we decide to stop. In this manner, text that sounds relatively correct and appropriate can be created from source text with no other human input.

In this generator, additional techniques are used in order to generate speeches of various lengths, with multiple characters, and with relatively correct grammar.

1. Select Scenes:

2. Select Characters:

3. Generate

Lines:
Chain Length:
Speech Size:
+/-
%
Line Length:
+/-
%