Home For Fiction – Blog

for thinking people


Programming

Fiction Complexity Index: Calculate Your Novel’s Genre Positioning

June 17, 2020

Romance novels aren’t as complex as literary fiction. Similarly, historical fiction is more complex than, say, young-adult fantasy. I’ve been thinking, we need a Fiction Complexity Index. Moreover, we need a Fiction Complexity Index by genre; a number that can give us a rough estimate of whether our novel is “about right” in terms of complexity.

And so, I decided to make one!

The good news is, this little Fiction Complexity Index is something you, too can benefit from. Because I decided to code it in a way that allows anyone to upload their novel (as a .txt file) and immediately see the results.

Fiction complexity index
A Fiction Complexity Index can help us see whether a text is suitable for the intended genre
(more…)

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