Original by Christopher Strachey, written for the Manchester Mark I in 1952. Read more here.
Vocabulary based on this implementation.
sal_adjs = [
"Delicious",
"Exquisite",
"My",
"Juiciest",
"Vibrant",
"Sweetest"]
sal_nouns = [
"Pamplemousse",
"Pear",
"Guava",
"Pommegranade",
"Avocado",
"Passion Fruit"
]
adjsSelf = [
'affectionate',
'amorous',
'anxious',
'avid',
'beautiful',
'breathless',
'burning',
'covetous',
'craving',
'curious',
'eager',
'fervent',
'fondest',
'loveable',
'lovesick',
'loving',
'passionate',
'precious',
'seductive',
'sweet',
'sympathetic',
'tender',
'unsatisfied',
'winning',
'wistful'
]
nounsSelf = [
'appetite',
'craving',
'desire',
'fancy',
'intestines',
'fervour',
'hunger',
'taste',
'passion',
'tastebuds',
'thirst',
'lips',
'mouth'
]
nounsFruit=[
'shape',
'flavour',
'taste',
'texture',
'peal'
]
advsSelf = [
'affectionately',
'ardently',
'anxiously',
'beautifully',
'burningly',
'covetously',
'curiously',
'eagerly',
'fervently',
'fondly',
'impatiently',
'keenly',
'lovingly',
'passionately',
'seductively',
'tenderly',
'wistfully'
]
adjsFruit = [
'tomato',
'alien',
'delecius',
'perfect',
'bumpy',
'round',
'sweet',
'smooth',
'nectarous',
'crispy'
]
verbsSelf = [
'adores',
'attracts',
'devours',
'holds dear',
'eat for',
'hungers for',
'likes',
'longs for',
'loves',
'lusts after',
'pants for',
'pines for',
'sighs for',
'squeeze',
'thirsts for',
'treasures',
'yearns for',
'woos'
]
verbsFruit=[
'explossion',
'secretion'
]
# textwrap library used to "wrap" the text at a particular length
import textwrap
import random
# output begins with salutation
output = random.choice(sal_adjs) + " " + random.choice(sal_nouns) + ",\n"
output += "\n"
# inside this loop, build the phrases. strachey implemented "short" phrases
# and "long" phrases; two or more "short" phrases in a row have special
# formatting rules, so we need to know what the last phrase kind was in
# order to generate the output.
history = []
body = ""
for i in range(5):
kind = random.choice(["short", "long"])
if kind == "long":
# adjectives and adverbs will be present only 50% of the time
line = " ".join([
"My",
random.choice([random.choice(adjsSelf), ""]),
random.choice(nounsSelf),
random.choice([random.choice(advsSelf), ""]),
random.choice(verbsSelf),
"your",
random.choice([random.choice(adjsFruit), ""]),
random.choice(nounsFruit)])
body += line
else:
adj_noun = random.choice(adjsSelf) + " " + random.choice(nounsSelf)
# if the last phrase was "short," use truncated form
if len(history) > 0 and history[-1] == "short":
body += ": my " + adj_noun
else:
body += "You are my " + adj_noun
body += ". "
history.append(kind)
# clean up output
body = body.replace(" ", " ")
body = body.replace(". :", ":")
# put everything together
output += textwrap.fill(body, 60)
output += "\n\nYours " + random.choice(advsSelf) + ",\n"
output += "Joe T."
print(output)