I was looking at a Software Developer posting on the FreshBooks careers page the other day, and near the end of the “How to apply” instructions there was a curious sentence:
“If you want to prove you’re really paying attention, include a verse of ottava rima and a link to your GitHub profile with your application and you’re guaranteed to have your application reviewed by our Software Development Manager.”
I’d never heard of the ottava rima rhyming stanza form before, but a quick trip to Wikipedia remedied that. Essentially, an ottava rima stanza must satisfy three rules:
- Each stanza must have 8 lines,
- The lines must be iambic pentameter,
- The stanza must have the rhyming format a-b-a-b-a-b-c-c.
Here is an example of an ottava rima stanza by Frere (as given in the Wikipedia article):
But chiefly, when the shadowy moon had shed
O’er woods and waters her mysterious hue,
Their passive hearts and vacant fancies fed
With thoughts and aspirations strange and new,
Till their brute souls with inward working bred
Dark hints that in the depths of instinct grew
Subjection not from Locke’s associations,
Nor David Hartley’s doctrine of vibrations.
The simplicity of the rules got me thinking: how hard would it be to write a program to check if a poem stanza is ottava rima?
In this article, we will write a simple ottava rima detector in PHP.
(If you’re not interested in the details, you can skip to the code at GitHub.)
Read more »