Skip to content

Instantly share code, notes, and snippets.

@michaeluzzi
michaeluzzi / grey-album.py
Last active December 16, 2015 01:39
Feeding lyrics from the White Album and Black Album to a Markov chain generator to create "Grey Album" lyrics.
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)
@michaeluzzi
michaeluzzi / nonsense.py
Created March 13, 2013 19:44
This program generates random poems that contain zero English words
# This program generates random poems that contain zero English words
import random
import re
# create dictionary using scrabble dictionary plus 'a' and 'i'
dictionary = []
for line in open('sowpods.txt'):
line = line.strip()
dictionary.append(line)
@michaeluzzi
michaeluzzi / kimye_sorted_words.py
Created February 27, 2013 18:42
Outputs the words of Kim and Kanye's tweets, sorted.
import sys
all_concordance = dict()
for line in open('kim-tweets.txt'):
line = line.strip()
line = line.replace(".", "")
line = line.replace(",", "")
line_words = line.split(" ")
for word in line_words:
@michaeluzzi
michaeluzzi / kimye.py
Created February 27, 2013 18:07
Outputs random poems using the tweets of Kanye and Kim and input.
import sys
import random
all_words = list()
for line in open('kim-tweets.txt'):
line = line.strip()
line = line.lower()
line = line.replace(".", "")
line = line.replace(",", "")
@michaeluzzi
michaeluzzi / one_and_two_letter_words.py
Created February 13, 2013 21:19
This program prints out only the one and two letter words in a given text.
import sys
myWords = []
for line in sys.stdin:
line = line.strip()
words = line.split(" ")
for word in words:
if len(word) < 3:
myWords.append(word)