Capstone Project

Reza Rosli @hackplay.net
25 January 2016

Predicting Poetry

Introduction

I took the road less traveled by, and based my prediction model on samples from blogs, news and twitter and the 'Complete Poems of Robert Frost' in order to create some contemporary word combinations with more poetic phrases such as similes, and unusual words.

I had hoped in this way to get some interesting word predictions, and explore creative ways of applying my learnings in the art of making poetry.

How It Works Under The Hood

  • Words are predicted from a hashed lookup table of 2-,3-,4-, and 5-grams from the sampled texts.
           key    val freq
80 -1984379713    the   26
81  1178941954   know   26
82  1178941954 should   26
83   759748795     it   26
84   455566107     to   26
85  -423038880  night   26
  • As the user types in words, the input is converted into a hash and the next word is searched from the val column using the hash as the key.
  • The search is conducted from 5-gram, and increasingly less -gram until a match is found. If no match is found at 2-gram than the word “the”, which is the most common word in English is suggested.

Try It! Make A Poem!

You can use my app to key in some phrases and get word suggestions which might likely be used by the great Robert Frost. Continuously add lines to build your own poem!

I could find ways to make it better by including works from other poets and improving the prediction algorithm e.g. to find rhyming words at the end of lines.

See my project at zaros.shinyapps.io/Capstone_Submission.

Enjoy!

zaros @hackplay.net