Home For Fiction – Blog

for thinking people

New post every MondayHow not to miss one

iambic

An Iambic Pentameter Checker in JavaScript

January 15, 2024

My iambic pentameter generator has been one of the most popular posts of the blog. To be honest, I’m not sure if that’s still the case or not. Since I completely revamped the blog (actually even earlier), I removed Google and Jetpack analytics. In any case, today we’ll be looking at, essentially, the reverse scenario: We’re making a very simple iambic pentameter checker.

Just in case you need a reminder, an iambic pentameter line consists of ten syllables, of which every other is stressed. For instance, “And you, my sinews, grow not instant old” (from Hamlet).

So, how can we create a JavaScript iambic pentameter checker that tells us if a line is an iambic pentameter or not?

iambic pentameter checker, AI render of Shakespeare using a computer
I couldn’t resist using AI to generate this image of Shakespeare using a laptop. Like all tools, AI tools can be fun and useful, if one understands their limitations…
(more…)

Making a Rhyming JavaScript Shakespearean Sonnet Mixer

January 13, 2020

My JavaScript iambic pentameter generator is among the most popular programming posts on Home for Fiction. It’s a really “alpha” piece of code which I haven’t worked on since I made that first version. But here’s a little something to compensate: let’s make a rhyming JavaScript Shakespearean sonnet mixer!

Unlike the iambic pentameter generator, this JavaScript Shakespearean sonnet mixer returns much more coherent results. After all, the code doesn’t need to generate any random text. It simply shuffles the Bard’s own production.

For a relevant project, also take a look at my poem shuffler.

To keep things simple, I decided to have it generate only two rhyming lines. The more the lines, the slower it would get – and the more likely it would not find any rhyming pairs.

JavaScript Shakespearean sonnet
To code or not to code?
(more…)

A JavaScript Iambic Pentameter Generator

June 13, 2018

First of all, before I explain why I made an iambic pentameter generator, we need to know what an iambic pentameter is.

Chances are, if you found this article you already know, so I’ll be brief. An iambic pentameter is a line of poetry consisting of five “feet”, or groups of syllables. “Penta” in Greek means “five”, so pentameter means that the line consists of five groups of syllables. The iamb refers to a pair of syllables where the first is unstressed and the second is stressed. For instance, the word desPAIR (capitals indicate the emphasis). Hence, an iambic pentameter line consists of ten syllables, of which the 2nd, 4th, 6th, 8th, and 10th are stressedTechnically, this is not necessary. What should occur is that the rest of the syllables (1st, 3rd, 5th, 7th, 9th) are not  stressed..

Here’s four lines of iambic pentameter:

And you, my sinews, grow not instant old
But bear me swiftly up. Remember thee?
Ay, thou poor ghost, whiles memory holds a seat
In this distracted globe. Remember thee?
(Hamlet, I.v.94–97)

And now, without further delay, let’s get to the why’s and how’s of the iambic pentameter generator.

iambic pentameter generator in JavaScript
The Bard would approve!
(more…)