Skip to main content

Simple markov chain implementation

Project description


PyMarkovChain supplies an easy-to-use implementation of a markov chain text generator.
To use it, you can simply do

#!/usr/bin/env python

from pymarkovchain import MarkovChain
# Create an instance of the markov chain. By default, it uses's location to
# store and load its database files to. You probably want to give it another location, like so:
mc = MarkovChain("./markov")
# To generate the markov chain's language model, in case it's not present
mc.generateDatabase("This is a string of Text. It won't generate an interesting database though.")
# To let the markov chain generate some text, execute

To store its data, PyMarkovChain simply uses pickle to dump all of its data to disk.
This entails that you have to use the same version of python to store the data and to
restore the data, as pickle is one of those things that have changed from python2 to python3.

See also [code on github]( and [PyPI page](
To install, simply use pip like so:
pip install PyMarkovChain

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for PyMarkovChain, version 1.8
Filename, size File type Python version Upload date Hashes
Filename, size PyMarkovChain-1.8.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page