Tonight, Why posted some lovely Ruby haiku, which reminded me of a program I’ve been dreaming of writing for a few years now. So, I sat down and started it.

It takes a body of text, and attempts to automatically extract random haiku from it ("haiku" in this case being mis-defined as any text that conforms to the 5/7/5 syllable pattern).

I ran it against the raw text of my weblog and generated some really heavy stuff, man:

  Time is running out.
  If you own a home (or rent?)
  The answer is "no".

  Climbing on my head!
  Do you have an idea?
  Don't do crack cocaine.

  "weird cryptic syntax"?
  would take a *lot* of practice.
  Don't even
  try it.

  The answer is "no".
  Code Generation is New?
  (A week late, I know.)

The program uses Lingua::EN::Sentence and Lingua::EN::Syllable, which made it completely trivial to write.

I can imagine, given a sufficiently large body of input text and a Latent Semantic Indexing search engine, you could make some super-cheesey poetry with it.

The code is here if you’re interested.