Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sequitur/improv
A model-backed generative text library for JavaScript.
https://github.com/sequitur/improv
Last synced: 3 days ago
JSON representation
A model-backed generative text library for JavaScript.
- Host: GitHub
- URL: https://github.com/sequitur/improv
- Owner: sequitur
- License: mit
- Created: 2016-01-25T13:46:49.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T19:07:59.000Z (almost 2 years ago)
- Last Synced: 2024-04-15T00:13:03.765Z (7 months ago)
- Language: JavaScript
- Size: 1.79 MB
- Stars: 138
- Watchers: 7
- Forks: 10
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Improv
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status](https://david-dm.org/sequitur/improv.svg)](https://david-dm.org/sequitur/improv) [![Documentation Status](https://readthedocs.org/projects/improv/badge/?version=latest)](http://improv.readthedocs.org/en/latest/?badge=latest)
A model-backed generative text grammar tool for javascript. Improv is similar to Tracery in that it can generate random, procedurally generated text recursively. Also like Tracery, Improv includes some basic templating functionality.
Unlike Tracery, however, Improv generators refer to *models* to build text. This allows for more sophisticated text generation by referencing an underlying world model.
## Installation
Improv is an npm module, but it should work fine in a browser environment through Webpack or Browserify.
```sh
$ npm install --save improv
```## Quick Example
```js
import Improv from './lib/index.js';const spec = {
animal: {
groups: [
{
tags: [['class', 'mammal']],
phrases: ['dog', 'cat']
},
{
tags: [['class', 'bird']],
phrases: ['parrot']
}
]
},
root: {
groups: [
{
tags: [],
phrases: [
'[name]: I have a [:animal] who is [#2-7] years old.'
]
}
]
}
};const improv = new Improv(spec, {
filters: [Improv.filters.mismatchFilter()]
});const bob = { name: 'Bob' };
const alice = { name: 'Alice', tags: [['class', 'mammal']] };
const carol = { name: 'Carol', tags: [['class', 'bird']] };const lines = [
improv.gen('root', bob),
improv.gen('root', alice),
improv.gen('root', carol)
];/* Should produce something like:
Bob: I have a dog who is 3 years old.
Alice: I have a cat who is 2 years old.
Carol: I have a parrot who is 5 years old.
*/console.log(lines.join('\n'));
```## Documentation
Full API documentation at [Read the Docs].
## Caveats and Known Issues
Improv does absolutely no validation or security checking of anything, so for the love of God don't pass user-submitted data into it.
Improv is still in active development and the API will change in the future as the library evolves.
## License
MIT © [Bruno Dias](http://segue.pw/)
[npm-image]: https://badge.fury.io/js/improv.svg
[npm-url]: https://npmjs.org/package/improv
[travis-image]: https://travis-ci.org/sequitur/improv.svg?branch=master
[travis-url]: https://travis-ci.org/sequitur/improv
[daviddm-image]: https://david-dm.org/sequitur/improv.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/sequitur/improv
[Read the Docs]:http://improv.readthedocs.org/en/latest/