Home For Fiction – Blog

for thinking people

Patreon LogoPatreon

programming

A JavaScript Random Text Generator

June 6, 2020

Virtually all of my coding revolves around text, one way or another. Just to name two examples, see my rhyming anapest generator or my Gothic analyzer program. In this post, I decided to make something a bit mad, so I came up with a very simple (but very funny!) JavaScript random text generator.

But this isn’t just any random… random text generator like, say, my random quote generator. This little program – in only 10 lines of code – combines text from different sources and returns a set of randomized sentences.

If this sounds somewhat familiar, it’s very similar to my Ghostwriter Android app.

The difference is, this time I decided to i) code it in JavaScript (rather than Java); ii) use the first two chapters of two of my novels, Illiterary Fiction and The Other Side of Dreams to generate the results.

JavaScript random text generator
Why write a text with a pen, when you can write it with a JavaScript random text generator [/tongue-in-cheek]
(more…)

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