Skip to content

ddycai/random-sentence-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Random Sentence Generator

Generate random sentences based on an input file using Markov chains.

python generate_from_file.py input.txt -c chain_length

Chain length is the number of words to look back when generating a new word. Setting chain length to be too high (> 3) will result in sampling sentences verbatim out of the text.

The Wizard of Oz text is included for testing. You can generate a sentence using:

python generate_from_file.py wizard_of_oz.txt

Generate random sentences using the Generator class. (see example of use in generate_from_file.py)

from sentence_generator import Generator
generator = Generator(sentences, chain_length)
print(generator.generate())

Requirements:

About

Generate random sentences from input text.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages