Skip to content

Instantly share code, notes, and snippets.

@hamilton
Created January 14, 2010 18:12
Show Gist options
  • Save hamilton/277363 to your computer and use it in GitHub Desktop.
Save hamilton/277363 to your computer and use it in GitHub Desktop.
A short demo on how to use Rhymeless.
>>> from rhymeless import Rhymeless
>>> poem_generator = Rhymeless()
>>> book = open("books/on_the_origin_of_species.txt", "r")
>>> lines = []
>>> for line in book:
... lines.append(line)
...
>>> book = "".join(lines)
>>>
>>> # the book variable is just a huge string. I could also train
>>> # on individual strings, or tweets, or virtually any other
>>> # plain text content.
>>>
>>> poem_generator.train(book)
>>> print poem_generator.generate_poem()
The number of distinct classes
Cause the slight alterations, generation
Layer, and genera of grasses.
To me, no explanation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment