Inspired by soulwire's mad-libs style random sentence generator, and remixed to be appropriate for all audiences who are interested in thinking about the future.
It's very simple to use and now allows you to populate it using either vanilla JavaScript objects, JSON files or direct feeds from Google spreadsheets.
To make your own, simply clone or download this repository and start populating the engine with your content.
You can populate it using one of three different methods. Each is controlled from main.js
(where you will find commented examples of each technique.)
- JavaScript Object literal
- A JSON file
- A live feed from a Google spreadsheet
If you choose to use a Google spreadsheet, you must publish it first and be sure to manually republish it after editing if you want changes to propagate immediately, otherwise they will take around 15 minutes.
Here's an example spreadsheet, which you can clone and use a base for your data source.
Note: For local testing (when using loaded JSON or Google spreadsheet data), you'll need to serve the site from a local webserver. You can easily do this using tools like SimpleHTTPServer for Python or http-server for Node.
The process is very simple. The WTF Engine takes a sentence template and fills in different types of blanks with different types of words, much like the game Mad Libs. You can nominate any amount of templates and as many different categories of words or phrases as you like.
For example, here is a basic corpus
{
template: [ "Big @color @animal", "Silly @animal with @color fur" ],
animal: [ "dog", "cat", "rabbit" ],
color: [ "red", "blue", "green", "yellow" ]
};
As you can see, in a template you use the @ symbol, followed by the type of word you wish to use to tell the WTF Engine to pick a random word of that type from the corpus and insert it at that point.