Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.rst Tweaking reST for github Dec 28, 2010
shakespeare_sonnet.txt Markov poem generator Dec 28, 2010
sonnet.py Markov poem generator Dec 28, 2010

README.rst

Markov Text Generator

This is a simple Markov text generator that has been customized to generate poem like output using sonnets written by Shakespeare [1] as the source material. Inspired by this article from Coding Horror [2], and loosely based on the code from the Usware Blog [3].

Some of the changes I made were to consider line counts instead of word counts for termination and a reseeder to continue word generation if a matching key could not be found for the next state. In addition I emit some statistics about the database constructed such as the number of key entries and the mean and standard deviation of the number of possible words generated by each key.

This is written and tested in Python 2.6.1, no extra batteries required.

[1]
  1. Shakespeare. Shakespeare's Sonnets. [Online]. Available: http://www.gutenberg.org/cache/epub/1041/pg1041.txt
[2]
  1. Atwood. (2008, Jun.). Markvov and You. [Online]. Available: http://www.codinghorror.com/blog/2008/06/markov-and-you.html
[3]Shabda. (2009, Jun.). Generating pseudo random text with Markov chains using Python. [Online]. Available: http://uswaretech.com/blog/2009/06/pseudo-random-text-markov-chains-python