Python Poem Generator

Our Reading and Writing Electronic Text Midterm projects consists of two steps:

  • Devise a new poetic form.
  • Create a computer program that generates texts that conform to new poetic form you devised.

Initially I wanted to create a haiku generator. Unfortunately there are not a lot of online resources dedicated to breaking english words down by syllable. Instead, I settled on a poem generator.

The python script scrapes a random word generator at Vocubula.com, where it gets the word and the word’s part of speech. From there I organize the words according to parts of speech inside a dictionary, where the part of speech is the key, and the values are lists filled with the words.

I also scraped a list of prepositions to insert into the poem structure.

The poem structure itself is four lines, and each line is a simple sentence structure.

The poem generator has created works such as:

cacography popple incunabulum through the exuviae nympholepsy versus ensorcell skeuomorph inhere subfusc triumphalism cosmography disabuse by means of gourmand

Or:

detritus perambulate bacronym against the caducity Weltschmerz in front of enucleate suborner notional soi-disant succedaneum zoophyte embay modulo gourmandise

And finally:

quatopygia straiten menology neath the anonym incubus left of transude quiddity perambulate chthonic juvenilia maenad ameliorate above zenana

The output reads like a Harry Potter spell. While it’s not very impressive, perhaps there are more variations in the line structure to investigate.

The code is available here: Github.

Comments