Skip to content
Procedurally generate text with JavaScript
JavaScript HTML CSS Perl Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.sass-cache/1d5df39efda0435fcca644c32abbdf86fdb1a57f Added autocomplete to input textarea Dec 23, 2014
dist added dist Jun 23, 2016
example updated structure Jun 23, 2016
ext updated structure Jun 23, 2016
gulp Updated scripts Jun 23, 2016
resources Added RantVocab submodule Jan 11, 2016
scripts Added tagging instructions Jun 28, 2016
server Added option for adding sample dictionaries Jun 23, 2016
source updated dictionary Jun 23, 2016
spec CommonJS support Dec 25, 2014
static Updated lexer Jan 2, 2015
test test for repeated nsfw Dec 27, 2014
.flowconfig
.gitignore Updated scripts Jun 23, 2016
.gitmodules Added RantVocab submodule Jan 11, 2016
.npmignore updated structure Jun 23, 2016
README.md updated structure Jun 23, 2016
config.js Added option for adding sample dictionaries Jun 23, 2016
gulpfile.js
index.js v0.7 Dec 4, 2014
package.json Added tagging instructions Jun 28, 2016
package.npm
style.scss Added autocomplete to input textarea Dec 23, 2014

README.md

Rantjs

Rantjs is a procedural text generator. The goal is to augment human creativity with the boundless potential of randomness. Inspired by Rant.

The project is available via npm (do npm install rantjs).

Demo and more information

Interactive demo available here

Click here for a writeup on my blog

Usage

var rant = require("rantjs");
var sentence=rant('<firstname male> likes to <verb-transitive> <noun.plural> with <pron poss male> pet <noun-animal> on <timenoun dayofweek plural>.');

console.log(sentence); // 'Sean likes to chop parrots with his pet cat on Saturdays.'

For implementation details, please visit the npmjs page

Install

git clone https://github.com/svenanders/rantjs && cd rantjs
npm i
gulp serve

Then open http://localhost:8000

Development Plan

Easy way to choose alternative dictionaries

Indefinite article (a/an) automation

Overwriting (targets)

Capitalisation

Looping (repeaters)

Conditionals

Contributions

Contributions are welcome. Feel free to submit an issue/pull request. The following areas are of particular interest:

Documentation (wiki/code)

Fixing bugs

Optimization

Functions in the development plan

New language features

Testing. Currently, this is the result of the coverage report:

Statements   : 96.44% ( 461/478 )
Branches     : 67.65% ( 46/68 )
Functions    : 100% ( 18/18 )
Lines        : 97.24% ( 458/471 )

Ideally, it should be 100% on everything

New in version 1.0.0

Added option for custom dictionaries. Note that this replaces the built-in dictionary.

var yourCustomDic = {}
...
rant('your text', yourCustomDic);

A sample dictionary file can be found in the ./src folder. Also take a look at the built-in english dicionary in the same folder for reference.

New in version 0.9.x

0.9.7 - Added nonsense verbs from Rantionary

0.9.5 - Added verbs for success and defeat

0.9.4 - Added Death ()

0.9.3 - Added climb (<verb climb up|down>)

New in version 0.9.1

Rewrote Rantjs for CommonJS.

Removed several gulp tasks (concat, minify)

Refactored the tests

Renamed the app internally

New usage syntax (not compatible with 0.8.x)

You can now call Rantjs directly from require:

var sentence=require("rantjs")("<firstname male> likes to <verb-transitive> 
<noun.plural> with <pron poss male> pet <noun-animal> on <timenoun dayofweek plural>.");

Added randomization:

require("rantjs")("A random string: [rep:8][sep:\N]{\C}");
//A random string: XUACJGOGN

New in version 0.8.6

Added support for [rep:x]

Usage:

[case:title][sep:\n][rep:3]{I like <noun animal plural> but not <noun animal plural>}

// I Like Ogres but not Turtles
// I Like Bulls but not Horses
// I Like Poodles but not Owls

Note: [sep:\n] dictates newlines. Alternatively, you can specify \s for space.

New in version 0.8.5

Added support for [case]-tag.

Usage:

[case:upper]<firstname male>

Variants:

[case:none|default|word|upper|lower|case|sentence]
You can’t perform that action at this time.