GithubHelp home page GithubHelp logo

rantjs's Introduction

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]

rantjs's People

Contributors

kangabell avatar robbestad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rantjs's Issues

Cannot find module 'en_US'

When I attempt to use any of the repeat syntax ([rep:3]), I receive this error:

Error: Cannot find module 'en_US'
  at Function.Module._resolveFilename (module.js:338:15)
  at Function.Module._load (module.js:280:25)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at braceParser (/Users/brekk/Servers/test/node_modules/rantjs/braceParser.js:43:17)

My example code:

var rant = require('rantjs');
var x = rant('[rep:8]{<adj nsfw>}');

Add git tags

Hi @svenanders ,
We are cdnjs team.
Because we prefer to use dist folder and the name with meaning, we decide to grab files from GitHub instead of npm.
But the git auto-updater in cdnjs relied on git tags so that it can recognize the correct version and automatically update the repo.
Could you please add git tags for the repo? Thank you.

cdnjs/cdnjs#7698
cdnjs/cdnjs#8343

Strange output from default pattern

I tried the default pattern on your page and got this:

screenshot

Two anomalies appear in the output: appearance and undefined. I am assuming that these are unintentional, so I thought I'd let you know.

Incorrect block behavior

I started playing around with your online demo and wanted to point out a few important block features that I noticed were missing.

Plain text in blocks does not work.

First, I tried creating a block with some normal text in it.
screenshot
It doesn't appear to print anything. According to the original specification, it should print the same text as if it weren't in the block:

Example text

Repeaters don't work with plain text.

Calling rep followed by a block containing a raw string prints nothing, no matter how many repetitions are specified. It seems to only work with a single query. If rep is not called, a block is ignored.
screenshot

If a block has no repetitions specified, it should always be assumed that the block will be read one time.

Blocks do not appear to support multiple elements.

Since blocks currently only support lone queries, I decided to test multiple item selection. This doesn't appear to be supported yet, either.
screenshot
Each repetition should randomly select a noun, adjective, or verb.


I understand that Rantjs is still in early development, and perhaps you were already planning to fix these things, but I thought I'd write this up just in case you missed any of them by mistake.

A friend of mine recently rewrote all of the Rant documentation. You can find it here. If your aim is to go with the original language spec, you might find it useful as a reference.

Seed based generation

How difficult would it be to implement seed based generation or using a custom random number generator?

any plans for node?

This project looks great!

Any plans for node support? Using modules (ES6 / CommonJS) would probably clean up your build step quite a lot as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.