Generative poetry
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
preprocessed
public
sources
.env
.gitignore
Gemfile
Gemfile.lock
README.md
cal_in_the_hacks.rb
cli.rb
poem.wav
related_words.rb
rhyming.rb
sentence_builder.rb
server.rb
seussifier.rb
test.rb
word_types.rb

README.md

Cal In The Hacks

A poetry generator, trained from The Wizard of Oz and The Great Gatsby.

Live demo: http://poetry.davepagurek.com

Video: https://www.youtube.com/watch?v=j93TF18AdKE

Setup

# Install gsl
brew install gsl # for Mac
sudo apt-get install libgsl0-dev # for Linux

# Install ruby dependencies
bundle install

Running

ruby server.rb

How it works

Rhyme scheme

The Cal in the Hacks works by making a matrix, where one axis is rhymes and the other axis is related words. To make a poem with an AABB rhyme scheme, you make a sentence ending on a word in the matrix, then slide to a rhyming word for the end of the next sentence, then a related word for the next, and then rhyme for the next.

Verse generation

Sentences are generated by finding relevant passages in some source material (in our case, The Great Gatsby and The Wizard of Oz) that are around the right number of syllables. Multiple options are ranked by their relevancy to the subject of the line. This is done by training a word-to-vector model on the source text and ranking based on vector distance to the subject.

Text-to-Speech

We use the IBM Watson API and HTML5 Audio to read the poetry for you. (This has since been turned off in the live site because our api key will expire eventually.)