Home For Fiction – Blog

for thinking people

Patreon LogoPatreon

transitive verbs

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…)