Created
January 14, 2010 18:12
-
-
Save hamilton/277363 to your computer and use it in GitHub Desktop.
A short demo on how to use Rhymeless.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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