Skip to content

Instantly share code, notes, and snippets.

@wanderer
Forked from jart/gotham.py
Created August 23, 2012 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wanderer/3433357 to your computer and use it in GitHub Desktop.
Save wanderer/3433357 to your computer and use it in GitHub Desktop.
Gothic Poetry Generator
r"""
gotham
~~~~~~
Gothic Poetry Generator
"""
import sys
import random
import itertools
import argparse
them = ['angels', 'mourners', 'shadows', 'storm clouds', 'memories',
'condemned', 'hand of Heaven', 'stroke of death', 'damned',
'witches', 'corpses', 'vermin', 'vampire', 'drunkard']
them_verb = ['follow', 'hover', 'approach', 'loom', 'taunt', 'hear',
'laugh', 'surround', 'compell', 'scour', 'deliver']
adj = ['cold', 'dead', 'dark', 'frozen', 'angry', 'ghastly', 'unholy',
'cunning', 'deep', 'morose', 'maligned', 'rotting', 'sickly', 'petty',
'sharper', 'craven', 'bound', 'plaintive', 'mournful', 'rabid',
'quivering', 'enchanted', 'tremulous', 'stubborn', 'swift', 'cursed',
'haunted', 'wretched']
me_part = ['neck', 'heart', 'head', 'eyes', 'soul', 'blood', 'essence',
'wisdom', 'sword']
feeling = ['pain', 'horror', 'frenzy', 'agony', 'numbness', 'fear', 'love',
'terror', 'madness', 'torment', 'bitterness', 'misery',
'melancholy', 'plight', 'lust', 'unworthy']
angst = ['care', 'understand', 'question', 'consider', 'forget']
me_verb = ['flee', 'dance', 'flail madly', 'fall limply', 'hang my head',
'try to run', 'cry out', 'call thy name', 'beg forgiveness',
'bleed', 'tremble', 'hear', 'give', 'offer']
thing = ['kisses', 'poison', 'tokens', 'servitude']
action = ['sever', 'crush', 'mutilate', 'slay', 'wound', 'smite', 'drip',
'melt', 'cast', 'mourn', 'avenge', 'posses', 'thrust', 'make',
'free', 'absolve']
place = ['witching hour', 'gates of hell', 'door', 'path', 'death',
'doom', 'oblivion', 'life ending', 'Hell', 'nothingness',
'purgatory', 'void', 'earth', 'tomb', 'broken ground',
'barren land', 'swirling dust', 'night', 'time ending',
'domain', 'bed', 'sepulcher', 'demise']
def lorem_gotham(seed=None):
"""Gothic Poetry Generator
Uses Python generators to yield eternal angst.
When you need to generate random verbiage to test your code or
typographic design, let's face it... Lorem Ipsum and "the quick
brown fox" are old and boring!
What you need is something with *flavor*, the kind of thing a
depressed teenager with a lot of black makeup would write.
"""
if seed is not None:
random.seed(seed)
w = lambda l: l[random.randrange(len(l))]
er = lambda w: w[:-1]+'ier' if w.endswith('y') else (w+'r' if w.endswith('e') else w+'er')
s = lambda w: w+'s'
ing = lambda w: w+'ing'
punc = lambda c, *l: " ".join(l)+c
sentence = lambda *l: lambda: " ".join(l)
pick = lambda *l: (l[random.randrange(len(l))])()
while True:
yield pick(
sentence('the',w(adj),w(them),'and the',w(them),w(them_verb)),
sentence(ing(w(them_verb)),'me to',w(place)),
sentence('they',w(action),'my',w(me_part),'and',w(me_verb),'with all my',w(feeling)),
sentence(w(action),'my',w(adj),w(me_part)),
sentence('in',w(place),'my',w(feeling),'shall',w(me_verb)),
sentence(punc(',', er(w(adj)),'than',w(adj),w(feeling))),
sentence(er(w(adj)),'than',w(them),'in',w(place)),
sentence('i',w(me_verb),'in',w(feeling),'with',w(them)),
sentence('i',w(action),w(adj),w(thing),'to thee'),
sentence('O this',w(adj),w(adj),w(place)),
sentence('not even the',w(them),'can',w(them_verb),'me'),
sentence(punc('!','oh my',w(me_part)),punc('!','the',w(feeling))),
sentence('no one',s(w(angst)),'why the',w(them),w(them_verb + me_verb)))
def lorem_gotham_title(seed=None):
"""Names your poem
"""
if seed is not None:
random.seed(seed)
w = lambda l: l[random.randrange(len(l))]
sentence = lambda *l: lambda: " ".join(l)
pick = lambda *l: (l[random.randrange(len(l))])()
return pick(
sentence('why i',w(me_verb)),
sentence(w(place)),
sentence('a',w(adj),w(adj),w(place)),
sentence('the',w(them)))
def main(args):
"""I provide a command-line interface for this module
"""
parser = argparse.ArgumentParser(description='Gothic Poetry Generator')
parser.add_argument('-s', action="store", dest="seed", type=int)
arguments = parser.parse_args()
seed = arguments.seed
print
print "-~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~-"
print lorem_gotham_title(seed).center(50)
print "-~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~-"
print
poem = lorem_gotham(seed)
for n in range(16):
if n in (4, 8, 12):
print
print poem.next()
print
if __name__ == '__main__':
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment