Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/v21/tracery
Tracery: a story-grammar generation library for javascript
https://github.com/v21/tracery
Last synced: 1 day ago
JSON representation
Tracery: a story-grammar generation library for javascript
- Host: GitHub
- URL: https://github.com/v21/tracery
- Owner: v21
- Fork: true (galaxykate/tracery)
- Created: 2015-05-10T19:09:27.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-03-22T14:19:07.000Z (over 5 years ago)
- Last Synced: 2024-03-15T00:50:16.739Z (8 months ago)
- Language: JavaScript
- Size: 7.27 MB
- Stars: 126
- Watchers: 10
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tracery
Tracery: a story-grammar generation library for javascriptThis is my attempt to package up [Tracery](https://github.com/galaxykate/tracery/) as a Node library.
## Installation
This is hosted at npm, so it can be installed like so:
```bash
$ npm install tracery-grammar --save
```## Example usage
```javascript
var tracery = require('tracery-grammar');var grammar = tracery.createGrammar({
'animal': ['panda','fox','capybara','iguana'],
'emotion': ['sad','happy','angry','jealous'],
'origin':['I am #emotion.a# #animal#.'],
});grammar.addModifiers(tracery.baseEngModifiers);
console.log(grammar.flatten('#origin#'));
```Sample output:
```plaintext
I am a happy iguana.
I am an angry fox.
I am a sad capybara.
```