Skip to content

Instantly share code, notes, and snippets.

@jart
Created August 23, 2012 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jart/3432955 to your computer and use it in GitHub Desktop.
Save jart/3432955 to your computer and use it in GitHub Desktop.
Gothic Poetry Generator
r"""
gotham
~~~~~~
Gothic Poetry Generator
"""
import sys
import random
import itertools
them = ['angels', 'mourners', 'shadows', 'storm clouds', 'memories',
'condemned', 'hand of Heaven', 'stroke of death', 'damned',
'witches', 'corpses', 'vermin', 'vampires', 'drunkards', 'convicts']
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', 'bitter', 'rustling']
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', 'humanity', 'dreary']
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', 'forsake']
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():
"""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.
"""
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'
cap = lambda w: w.capitalize()
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(cap(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(cap(w(action)),'my',w(adj),w(me_part),'to this',w(place)),
sentence('In a',w(place),'my',w(feeling),'shall',w(me_verb)),
sentence('A',w(place),'where',w(them),w(me_verb)),
sentence('To',w(them),'whose',w(thing),'be thy',w(feeling)),
sentence(cap(punc(',', er(w(adj)),'than',w(adj),w(feeling)))),
sentence(cap(er(w(adj))),'than',w(them),'in the',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('!','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():
"""Names your poem
"""
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
"""
print
print "-~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~-"
print lorem_gotham_title().center(50)
print "-~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~-"
print
poem = lorem_gotham()
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