Share your repls and programming experiences

← Back to all posts
📃 Poe - The Autonomous Poet (Major UI Update/Can now write Haikus)
joshwood (117)

How to use

After starting the program you will be greeted with the main menu. You will want to choose "Train Poe" to train Poe a text. You can then choose which text you would like to train Poe. There are a couple texts to choose from by default, but if you would like to train him using something else, simply just upload a .txt file of it into the texts folder. It will automatically show up in the list of available texts. You may also train it using multiple texts. Just train Poe one, then the next. He will remember both.

After you are finished training Poe, you will want to return to the main menu. Then choose to either generate a sonnet or haiku. After that, you will be prompted to enter the poem's topic. This can be anything as long as it is only one word. It works better to select a topic that relates to texts Poe wrote about.

Poe will then attempt to create a sonnet about the topic you chose. It usually will take him 10-20 seconds to do this, but it can sometimes take longer. The poem will be displayed on your screen as well as saved to poems.txt.

Poe will remember what you trained him after you generate a poem, so you can generate more poems without retraining him. If you want to train Poe using a different text, just choose the reset option and retrain him.

I recommend trying to train Poe using a variety of texts. You can get some pretty funny poems by doing that.

Example Poems

Sonnet about love: (Trained by a collection of Edgar Allen Poe's writing)

Sonnet about religion: (trained by The Bible):

Haiku about love (trained by the Timecube)

How it works

Poe creates sonnets by reading a large text and learning what words are commonly used alongside other words. The text that Poe is trained off of is "input.txt". He also uses the Datamuse API to find the syllables of a word as well as find which words rhyme with each other. Each time the Datamuse API is called, he parses and saves the response. This helps reduce the required API calls to create a sonnet which makes him faster as time goes on.

Planned Updates (in no particular order)

  • Train Poe from a web domain
  • Limerick creation
  • Improved stats
  • Improved code documentation
  • Bug fixes (primarily the line skip bug)

Update Log

  • Monday, February 4th - Poe first released
  • Wednesday, February 6th - Major UI overhaul, added support for training of multiple text files
  • Thursday, February 7th - Added support for Haikus

Known Issues

Sometimes Poe will fail to generate a single line and omit it from the sonnet. This will result in a blank line being printed where the line of poetry would've been. I'm working on finding the cause/solution.

This is one of my first large programming projects and I worked really hard on it. I appreciate any suggestion's/upvotes. :)
bgrubert (187)

Here's my Sonnet about Potatoes:

You and were in him lord shall be salted
It was with them when i came to my fruits
My lord said o lord would have exalted
Ye not let him before him in her roots

With him to mine hand of people and baked
But ye not in that came unto their flesh
Have ye are right hand against him and waked
Jesus said unto the people and fresh

Fought against thee in all that we were dried
Little children of them to all their dough
She was kindled against three in one side
Upon them and for them even as snow

The god and now o my children of spiced

bgrubert (187)

Really impressive! Congratulations!

NecrozmaSpin (10)

It's only time before someone trains it with the bee movie script.

RobaLobDob (6)

@NecrozmaSpin Thank you for the horrendous idea.

NicholasTapkas (1)

How on earth did you get the training time so low then get such high quality ouputs? It trains in a matter of seconds, then gives an output of an AI that's trained for days... Is this a Char-RNN AI? I really need to know.

joshwood (117)

@NicholasTapkas Haha I appreciate the enthusiasm but the output isn't that high of quality. Maybe you just got lucky and got some good ones on the ones you tried.

I'm not sure if the program even qualifies as a real AI. It just reads the input to find which words most commonly follow other words. It generates each line of poetry based off of the last word by adding a word onto the start of the line that commonly precedes the first word. I did a poor job explaining that. But it's considered a Markov Chain. It also does some extra stuff using the Rhymezone API to make the outputted lines the correct number of syllables and makes them rhyme. Also words that Rhymezone says fits within your topic are used more.

quockhanh (8)

got a crash . Some thing was wrong in the FileHandler file

joshwood (117)

@quockhanh Ok, it's fixed. I was copying some methods to the Filehandler class from another project and they pasted in with some messed up characters. Thanks for letting me know about it!

setheatonterry (1)

rlly cool, nice idea

Uselessharp_ (2)

this made me laugh

joshwood (117)

@Uselessharp_ Lol that's funny. What did you train it with?

pennywitepaw (2)

This is awesome! I am definitely going to stay up to date with the updates for the program!

AmeliaBlackwell (1075)

this is literally so cool; this is the sort of thing i wanna be able to make. i heard about how ai's can be made to compose music like this

joshwood (117)

@AmeliaBlackwell Haha thanks! Poe is a lot simpler than some of the AIs that make music, though.
If you want to learn how to make something like this, just take a look at my code. Or if you're having trouble understanding it take a look at the StudentBot AI. It works very similarly to this, but doesn't check for syllables/work with topics so it might be a little easier for you to understand.

AmeliaBlackwell (1075)

@joshwood I finished trying to make something similar! I did look at your code but I didn't really understand some of it, especially how you got the rhymes and stuff, so I just made my own. you can check it out if you want. i didn't know how to do topics so i just didn't haha.

AmeliaBlackwell (1075)

@joshwood warning, the produced poems don't make as much sense as yours

KiKUP (47)

Hey, I've been really motivated about making code, and I would like to learn how to make clean borders like you! I use python, and I would not like to stray out of python for now. Do you have any suggestions of how I can recreate your borders?
Also, I really love Poe! It's an easy AI to use, and it makes sense most of the time (for me at least)!

joshwood (117)

@KiKUP Haha thanks for the feedback. Glad you like it 😊.

To make the clean borders I used an alt code table to find the codes for the double lines. Here's a site you could use for that.

Then I made a function that would draw text with lines around it based on a predifined UI width. Take a look at my __printline() function that's part of my UI class. I also made a header and footer function. Feel free to copy my code or modify it if you'd like. Msg me on discord if you need more help. My username is skiboyec#1538.

KiKUP (47)

@joshwood Ah. Great, thank you for the information. I'm already working on a project that creates borders.

joshwood (117)

@KiKUP no problem! Lmk if you have any other questions.

Heekup (4)

This is really cool! Great job!

Scoder12 (802)

This is cool. Good job.

avibeskrowni (143)

Haiku about coding:
So on their errors
That her and complexity
Them and from the trait

joshwood (117)

@avibeskrowni You should publish it! haha

themaka (187)

Such Nice improvements!
Love me some haiku @joshwood.
Great contribution!

It won't make me a haiku about the word "determination" though -- just fails and gives me another prompt.

joshwood (117)

@themaka It worked for me. Maybe you misspelled the word?
This was trained with the bible.

themaka (187)

@joshwood Nice. Also, that's a good haiku!

Zavexeon (1178)

The new UI is awesome, dude!

joshwood (117)

@Zavexeon Haha thanks! I wanted to make it so people could try training it differently without the hassle of copying texts into the input. The code for the UI is kinda mediocre though. Part of it is like a bajillion nested if-statements which I need to fix.

Zavexeon (1178)

@joshwood Yeah. Things get complicated when you have if statements inside of if statements inside of if statements.

themaka (187)

This is very cool -- also like that you named it Poe. A telltale clue that your a fan of poetry.

joshwood (117)

@themaka Thanks for the feedback! I have to admit I'm not much of a poetry reader, though. I decided to make this program because some friends of mine were making nonsensical sonnets during a Shakespear unit in my English class. I thought I could make a program that could write sonnets as good theirs and it almost can (though that isn't saying much haha).
I named it Poe because I just read The Raven and The Tell-Tale Heart in English recently. I liked the two stories and I knew that Poe is a very well-known poet (although he hasn't written a ton of sonnets from what I've read).

21Miya (142)

This is really interesting and well-done, I've created randomized generators a lot because they're fun (so why not?), but incorporating AI into it works really well here. I might have to do something like this on my own eventually, you did a great job!

joshwood (117)

@21Miya Thanks! I appreciate it

Zavexeon (1178)

A poem about memes.... uh... okay.

Great program, by the way!

   Make out from him with us with the broadway
   A man and for many analogous
   Found it did not long and every day
   Will be found it for all analysis

   Let him from which were here analogy
   In that at first portion of me to fan
   To and of illustrious family
   Him with him and could not what means of man

   And was far as a hundred and surname
   I was an old man and his wicked jokes
   Was she was that of us and with a game
   For a long and that after all but hoax

   With it did not say that all at random
   It and appeared to a memorandum

One suggestion though is add some kind of exception for when it can't generate a poem based on the subject, because at the moment it gives you a error.

joshwood (117)

@Zavexeon thanks for the suggestion I'll add that tonight.
EDIT: This problem has been resolved I think.