Skip to content

yurimalheiros/markovtextgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Markov Text Generator

How to use

Import the module.

from textgen import TextGenerator

Create the generator, where k is the number of words considered as context.

generator = TextGenerator(k)

Generate the text, where n is the number of sentences generated.

generator.generate_text(n)

Example

from nltk.corpus import gutenberg
from textgen import TextGenerator

corpus = gutenberg.raw('shakespeare-hamlet.txt')

generator = TextGenerator(3)
generator.process_corpus(corpus)

print generator.generate_text(10)

About

Text generator using Markov chains

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages