The ancient art of 5-7-5 syllable poetry has now been fully automated.
(over the course of a few days in Python)
Push the button below to generate haikus, and let introspection and inspiration wash over you.
from js import document
from pyodide import create_proxy
import random
twononoun = ["slowly","cannot","creepy","beauty","gentle","trusting","making","always","standing","feeling","drowning","stranded","pulling","gently","silent","begin","begging","screaming","dying","living","wonder","very","dripping","giving","bleeding","sadly","melting","sneaky","sneaking","onto","sickly","breathing","beyond","destroy","painless","dirty","discuss","the last","running","in a","painful","sermon","deadly","ignored","remorse","the new","the old","ancient","cooking","speaking","goes to","enters"]
onenonoun = ["dumb","quaint","death","pushed","can","will","won't","with","kill","is","not","can't","in","tell","be","to","when","grief","sad","still","swim","tell","then","see","need","no","trapped","great","nice","cool","new","fair","cry","weak","dry","deep","soft","hard","bloom","flirt","pain","tear","but","split","hate","care","love","got","took","hit","rush","small","big"]
onenoun = ["tomb","rain","life","egg","trust","snow","leaf","plant","moon","food","wind","sky","star","sun","boat","ghost","land","sea","fun","pearl","lunch","spring","gold","tree","rose","ground","bed","cat","dog","breeze","storm","bath","dream","church","god","wolf","bridge","bench","breath","time","world","house","car","war","peace"]
twonoun = ["evil","window","breakfast","river","dinner","fire","demon","beetle","something","haiku","castle","tundra","justice","mountain","summer","winter","autumn","TV","rainbow","movie","lily","person","bunny","challenge","puppy","crystal","fortress","picnic","country","angel","mother","father","mansion","kitten","baby"]
threenonnoun = ["come with me","never there","beautiful","excellence","won't you please","skillfully","to believe","it's truly","not to last","a disgrace","commonly","beckoning","after all","could not be","always is","make it a","japanese","maddening","blossoming","ultimate","personal","in the end","while it can","what you are"]
threenoun = ["fireplace","factory","swimming pool","newspaper","parking lot","meeting place","symphony","hibachi","christmas time","red panda","bamboo stalk","gravity","lily pad","tomato","alcohol","unicorn","shrubbery","banana","history","serenade","chocolate","library"]
i = 0
global prevline
prevline = -2
global haiku
haiku = ""
def haikuline(syllables):
syllables = int(syllables)
i = 0
global haiku
haikupart = ""
while i < syllables-1:
apos = False
global prevline
rando = random.randrange(0,4)
if rando == prevline or rando == prevline-1 or rando == prevline+1:
prevline = rando
rando += random.randrange(-1,1)
if rando == prevline:
rando += 2
if rando == prevline+1:
rando += 1
if rando == prevline-1:
rando -= 1
prevline = -2
if rando > 3:
rando = 0
if rando < 0:
rando = 3
else:
if rando != prevline or rando != prevline-1 or rando != prevline+1:
prevline = rando
if rando == 0:
haikupart += twononoun[random.randrange(0,len(twononoun))]
i += 2
if i == 2 or i == 3 or i == 4 and apos == False:
rando2 = random.randrange(0,3)
if rando2 == 1:
haikupart += ","
apos = True
haikupart += " "
if rando == 1:
haikupart += onenonoun[random.randrange(0,len(onenonoun))]+" "
i += 1
if rando == 2:
haikupart += onenoun[random.randrange(0,len(onenoun))]
i += 1
if i == 2 or i == 3 or i == 4 and apos == False:
rando2 = random.randrange(0,3)
if rando2 == 1:
haikupart += ","
apos = True
haikupart += " "
if rando == 3:
haikupart += twonoun[random.randrange(0,len(twonoun))]
i += 2
if i == 2 or i == 3 or i == 4 and apos == False:
rando2 = random.randrange(0,3)
if rando2 == 1:
haikupart += ","
apos = True
haikupart += " "
if i < syllables-2:
done = False
rando2 = random.randrange(0,121)
if rando2 < 91:
done = True
if rando2 > 90 and done == False:
done = True
threetype = 0
if rando < 2:
threetype = 1
haikupart += threenoun[random.randrange(0,len(threenoun))]
if rando > 1:
threetype = 2
haikupart += threenonnoun[random.randrange(0,len(threenonnoun))]
i += 3
if threetype == 1:
prevline = 3
threetype = 0
if threetype == 2:
prevline = 0
threetype = 0
if i == 3 or i == 4 or i == 5 and apos == False and i < syllables:
rando2 = random.randrange(0,3)
if rando2 == 1:
haikupart += ","
apos = True
haikupart += " "
while i < syllables:
done = False
if i == syllables-1 and done == False:
i += 1
done = True
haikupart += onenoun[random.randrange(0,len(onenoun))]+" "
if i < syllables-1 and done == False:
i += 2
rando = random.randrange(0,2)
if rando == 0:
haikupart += twonoun[random.randrange(0,len(twonoun))]+" "
if rando == 1:
haikupart += twononoun[random.randrange(0,len(twononoun))]+" "
haiku = haikupart
def gen_haiku(self):
haikuline(5)
pyscript.write('haiku1', str(haiku), append=False)
haikuline(7)
pyscript.write('haiku2', str(haiku), append=False)
haikuline(5)
pyscript.write('haiku3', str(haiku), append=False)
function_proxy = create_proxy(gen_haiku)
document.getElementById("gen_haiku").addEventListener("click", function_proxy)
[Return to Home page]