articulate-nlg
Advanced tools
Comparing version 1.1.2 to 1.1.3
{ | ||
"name": "articulate-nlg", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A natural language generator (NLG) that articulates concepts as words, phrases, and sentences.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -17,2 +17,4 @@ [![Build Status](https://travis-ci.org/justinmahar/articulate-nlg.svg?branch=master)](https://travis-ci.org/justinmahar/articulate-nlg) [![codecov](https://codecov.io/gh/justinmahar/articulate-nlg/branch/master/graph/badge.svg)](https://codecov.io/gh/justinmahar/articulate-nlg) | ||
## Usage | ||
ES6 import: | ||
@@ -31,4 +33,2 @@ | ||
## Usage | ||
In short: | ||
@@ -54,5 +54,9 @@ | ||
const capitalize = VocabHelpers.capitalize; | ||
//const maybe = VocabHelpers.maybe; | ||
const say = VocabHelpers.say; | ||
const param = VocabHelpers.param; | ||
//const ifThen = VocabHelpers.ifThen; | ||
//const ifNot = VocabHelpers.ifNot; | ||
const ifElse = VocabHelpers.ifElse; | ||
//const doFirst = VocabHelpers.doFirst; | ||
@@ -114,18 +118,22 @@ // Here we have the greet, master, emoji, and welcomeHome concepts. | ||
Creates a template for capitalization. Capitalizes the first letter of the contents after articulating it. | ||
Creates a template for capitalization. Capitalizes the first letter of the text after passing it though the templating engine. | ||
### • `choose(texts: (string|{v:value,w:weight})[])` | ||
Creates a template for random choice. This chooses one of the items at random. Takes a mixed array of strings or weighted objects in the format `{v: value, w: weight}`. You cannot use a `|` character in any of the texts. If you need this character, use `say("pipe")` and have the `"pipe"` key map to `"|"`. | ||
Creates a template for random choice. This chooses one of the items at random. Takes a mixed array of strings or weighted objects in the format `{v: value, w: weight}`. | ||
Each item is articulated, meaning you can `say()` vocab keys. | ||
You cannot use a `|` character in any of the texts. If you need this character, use `say("pipe")` and have the `"pipe"` key map to `"|"`. | ||
Each text item is passed through the templating engine. This means you can use other helpers, like `say()`. | ||
- `choose(["apple", "orange", say("meat")])` -> Randomly selects `apple`, `orange`, or whatever `meat` articulates as. | ||
You can specify weights using `{v: value, w: weight}` objects instead of strings, where `v` is the text to articulate and `w` is the weight value. Weights default to `1` if not provided. | ||
- `choose([{v: "apple" w: 3}, "orange", "banana"])` -> `apple` has an 80% chance, `orange` and `banana` have a 20% chance (default weight of `1`). | ||
- `choose([{v: "apple" w: 3}, "orange", "banana"])` -> `apple` has a 60% chance, `orange` and `banana` each have a 20% chance (default weight of `1`). | ||
### • `maybe(text: string)` | ||
Creates a template that results in a 50/50 choice between an empty string or the provided text. | ||
Creates a template that results in a 50/50 choice between an empty string or the provided text. The same as using `choose(["", text])`. | ||
The provided text is passed through the templating engine. | ||
You cannot use a `|` character in the text. If you need this character, use `say("pipe")` and have the `"pipe"` key map to `"|"`. | ||
@@ -135,8 +143,10 @@ | ||
Creates a template that articulates another vocab key. | ||
Creates a template that cross-references another vocab key. | ||
### • `param(paramKey: string)` | ||
Creates a template that references the value of a parameter. | ||
Creates a template that references the value of a parameter. If it's a string, it will be part of the resulting text output. | ||
The value of the param is not passed through the templating engine. | ||
### • `ifThen(paramKey: string, thenText: string)` | ||
@@ -146,2 +156,4 @@ | ||
The provided text is passed through the templating engine. | ||
### • `ifNot(paramKey: string, thenText: string)` | ||
@@ -151,2 +163,4 @@ | ||
The provided text is passed through the templating engine. | ||
### • `ifElse(paramKey: string, thenText: string, elseText: string)` | ||
@@ -156,2 +170,4 @@ | ||
The provided text is passed through the templating engine. | ||
### • `doFirst(paramTextPairs: {p: paramKey, t: text}[], defaultText: string = "")` | ||
@@ -161,2 +177,4 @@ | ||
The provided text is passed through the templating engine. | ||
### Note on Nesting | ||
@@ -163,0 +181,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
107425
186