More Poetry? Oh Noetry!

For this project, we were to create another poem! Like the last project, we had to write a code in Python in order to generate a poem, but this time the poem had to have more structure. My poem needed to include poetry structure elements such as rhyme and meter. I was worried about having to come up with both of these elements as I am not a poetry-pro even when I try to write a regular poem on a regular piece of paper.

I tried to come up with different ideas for the poem template. I then decided to turn to Google, and I found numerous, numerous examples. Some were those of Dr. Seuss, some were those of Shel Silverstein, and others were random poems I had never read. After reading through many of the poems I was presented with, I finally decided on a template that I thought would be both fun to remix and also easy to remix.

I began to watch Dr. Whalen’s videos on YouTube. They were extremely helpful. I began to work through his example step-by-step along with him in the videos. This way, I would have a point of reference for myself, and I could get used to coding again in a more intensive way. I tried to figure out ways to stay one step ahead of him, but always fell short. Once I had watched about five ‘episodes,’ I decided it was time to work on my own template.

I typed my template into my Jupyter notebook like I did with the previous poem, and began to give each noun a value starting with {0}. As you can see below, the poem is kind of a long one. At first, I was going to try to complete the entire poem, but realized that this would be very difficult, as I would have about 17 lines to fill, while still maintaining rhyme and meter. I began to shorten the poem more and more to something more manageable. I looked back at Dr. Whalen’s videos, which did indeed help, but the poem was not going where I wanted it to. It was getting so complicated that I had to close it for the day and walk away from it. I needed a break. I could only withstand so many ERROR messages.

The original template for the poem:

Original template for my poem — Source

Finally, I woke up the next day and decided I was going to go for it head-on. I realized that I hadn’t watch Dr. Whalen’s bonus video, so I decided to watch it in hopes that it could help me. I was right! It helped me SO much! I began to write in my code, while also using some tips and tricks from Dr. Whalen. I decided that I only wanted to have about five stanzas in the poem, rather than 17. I had imported pycorpora, random, textblob, and pronouncing in order to help me and save me some time so I didn’t have to sit there and come up with hundreds of nouns that rhymed. My code began to look like this:

Once I had the template, I began to work through the code that would put everything together. I decided that from the pycorpora data, I would use the library of words classified under “personal_nouns.” ¬†This list included words such as “teacher,” “artist,” and more, some of which I definitely wouldn’t have classified or named as personal nouns. I also decided to use the library of words in pycorpora classified under “nouns.” This list of words basically included any noun you could ever think of. Things such as “skate,” “mayor,” “squad,” and many more. I continued to write conditional statements in order for the correct personal nouns and nouns to go into the correct places. I then wrote code in order for the amount of syllables for each personal noun and noun matched up. I also wrote code in order for the computer to find how many of the words are the correct number of syllables and rhyme with one another. When matches were found, they would be placed into my template to complete the poem.

Once I had the code finally complete, and the ERROR messages were no where in sight, I began to mess with the code a little bit in order for it to change. I changed the syllable count to be 1 syllable and then  2 syllables and then 3 so that we could get more of a variety. I know I could have just done it all at once, but I wanted to make the code as simple as possible so that I could understand it and then explain it at the same time. I then began to mess with the template, which I also know I could have written code for, but again, I wanted to make it my own, and I wanted to make it easy.

The final code looked a little something like this:

Now that the code was complete, it was time to have some fun! I began to run the code multiple times so that I could see as many iterations as I could. Here are some of my favorite examples:

My Code: MorePoetryOhNoetry

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.