Splain holds a special place in my heart as my first real public project. It was way too ambitious for me at the time, but over a few years,
I persisted and iterated until I saw the results I wanted. Although now completely superseded by LLMs, I am still proud of tackling something so unthinkably big to me at the time.
Splain is a template library to create varied and dynamic text. The basic idea is to build a dictionary of phrases correlating to tags. These could then be used recursively to build more complicated language.
(The following examples are heavily inspired by the Sims loading messages that I thought were just the funniest when I was younger.)
For example:
let Splain = require("./splain");
Splain.addEntry({
loading: {
message: [`loading {{loading.media}}`, `extracting {{loading.media}}`, `compiling {{loading.media}}`, `signing in`],
media: [`assets`, `images`, `effects`, `music`]
}
});
function showLoadingMessage() {
console.log(Splain.process(`{{loading.message}}`));
}
setInterval(showLoadingMessage, 5000);
The output of this could be something like loading assets or extracting media, and even in this simplified case, we gain the power of permutations to turn a few words into tens of different phrases.
This can then be built on to create more complicated language. For example:
Splain.addEntry({
message: [`{{loading.prefix?4loading.content loading.suffix?5}}`],
content: [`{{loading.verb loading.media}}`, `signing in`],
prefix: [`currently `, `please hold `, `skipping `],
suffix: [`, this is the tricky part!`, `...not much longer now`, `and failing`],
media: [`assets`, `images`, `effects`, `music`],
verb: [`loading`, `compiling`, `extracting`]
});
Splain grew with me as an operator, being re-written in TypeScript and used to explore build tools and collaboration. Right now, it gathers dust in my GitHub history, but I look back at it fondly and see
its influence in my later projects. For example, the idea for Good Morning AI was born from seeing the outputs of Splain
The examples here come from this tutorial.
You can see more examples of Splain in action: