An open API service indexing awesome lists of open source software.

https://github.com/keyan/markovgen

A module which generates strings from an input corpus using Markov chains.
https://github.com/keyan/markovgen

Last synced: about 1 year ago
JSON representation

A module which generates strings from an input corpus using Markov chains.

Awesome Lists containing this project

README

          

# MarkovGen
This module takes any string input and constructs a dictionary containing the frequency that following words occur. This can be used to probabilistically generate text which resembles the original input. The user can also specify how long to make the final output.

I had originally planned to add the option of accepting a user defined n-gram length, but I feel that I reached the point of diminishing educational return. Currently uses n-gram of 2, which generates decent, but oftentimes nonsensical text.

Usage: `python markov.py .txt <# of words>`

Some example text generate from [The Sayings of Confucius]:
>In awe he is stable a man with enquiries to another state

>Come from afar do we not rejoice to live unknown

>They are unprincipled stern men of arts and learning delights

>His face changed when he was asked what is meant by kindness without waste

I have also made this into a Flask web app, live @: [MarkovGen][mg]

[The Sayings of Confucius]: https://www.gutenberg.org/ebooks/24055
[mg]: http://www.keyanp.com