Home For Fiction – Blog

for thinking people

New post every MondayHow not to miss one

javascript

A JavaScript Transitive Verb Detector

April 24, 2020

Unsurprisingly, language, texts, and literature play a central role in my coding. On many occasions – for instance, with my iambic pentameter generator and my rhyming anapest generator, just to name two – one common issue has been that the code couldn’t separate transitive from intransitive verbs. Annoyed enough by that, I decided to code a JavaScript transitive verb detector.

Just in case you need a reminder, a transitive verb is one that can take one or more objects: “She drank water”. Conversely, an intransitive verb is one that cannot take an object: “He sneezed”. We can’t say “*He sneezed his nose” or something like that.

A JavaScript transitive verb detector is very useful when creating random text (as I often do). Without a transitive verb detector, some very peculiar random sentences can be formed, that are basically ungrammatical, like the one we saw above.

The best thing about this JavaScript transitive verb detector is that it’s fairly simple, too!

JavaScript transitive verb detector
A JavaScript transitive verb detector helps us determine the difference between “I see clouds” and “I fly”. Parenthetically, the code superimposed on the image is the actual code used (see the end of this post)
(more…)

Book Worming Party: When Literature Meets Drawing

February 20, 2020

For the past couple of months I’ve been working on a rather ambitious project. Ambition is often misunderstood, but the way I choose to approach it, it’s about doing something “just because”. It was in this “fuck it” framework that Book Worming Party, my latest programming project came to being.

Book Worming Party – even the name should tell you how mad this project is – combines three of my interests: literature, visuality, and programming. What can I say, I’m a talented man (and above all, modest).

Book Worming Party is a program (written mostly in JavaScript) that takes a work of fiction and, based on calculations and interpretations it makes about its nature, turns it into semi-random visual art. It translates words into color, plot into shapes, genre into affect. There are no separate “kinds of art”; art is art.

book worming party
Here’s what Book Worming Party generated from Jane Austen’s Pride and Prejudice
(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…)