Last active
December 16, 2015 01:39
-
-
Save michaeluzzi/5356796 to your computer and use it in GitHub Desktop.
Feeding lyrics from the White Album and Black Album to a Markov chain generator to create "Grey Album" lyrics.
This file contains hidden or 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
import random | |
from markov import MarkovGenerator | |
from markov_by_char import CharacterMarkovGenerator | |
# word MarkovGenerator | |
generator = MarkovGenerator(n=2, max=500) | |
# character MarkovGenerator | |
#generator = CharacterMarkovGenerator(n=3, max=100) | |
for line in open('white-album.txt'): | |
line = line.strip() | |
generator.feed(line) | |
generator.feed(line) | |
for line in open('black-album.txt'): | |
line = line.strip() | |
generator.feed(line) | |
for i in range(3): | |
print generator.generate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment