Saturday, February 26, 2011

Frogs

The next step after creating random word haiku was to incorporate a way to select words that go together based on some criteria.  I thought that a simple way to do this would be to feed the program a database of human-written haiku, and have it select the next word out of a haiku that the previous word was in.

I created a test haiku database, with 500 haiku that I found by using the preview feature on Google Books.  Then I wrote the code to do this.  It was a little bit tricky to write the code, so I was really happy once I'd figured it out and it was ready to go.  I had built quite a few precautions into it--for example, there is one line that prevents the program from selecting the same word twice in a row.  Or so I thought.

I ran it for the first line, and this is what it gave me:

frog frog frog frog frog


Obviously I had some more work to do.

1 comment: