trivisionzero

trivisionzero / MarkovChainTextGeneration / 0.1.0

README.md

Easily generate sentences from a large string of text using Markov Chains.

This algorithm takes a fairly large string of text, for example, a body paragraph from a book. and returns a sentence generated using a Markov chain algorithm.

You can input text as either a large string (algorithm will determine where sentences begin and end automatically), or a list of strings that are individual sentences. About 100 words are required to get a good output that is unlike any other sentence given in the input, sometimes more or less depending on the text. Too few and an exception will be thrown. Just above the minimum, and not many good results will be generated. A few paragraphs recommended for optimum results!

NOTE: Currently only accepts characters supported by Python strings (no accents and such). All other characters out of range will cause algorithm to fail. Will fix in a later update.

Call the algorithm by simply giving it either a string of a paragraph/paragraphs, or a string of sentences. The algorithm will take care of the rest.

Example below.

Sample text taken from http://www.public.asu.edu/~gelderen/hel/obletters.html