articulate-nlg
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "articulate-nlg", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "A natural language generator (NLG) that articulates concepts as words, phrases, and sentences.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -25,2 +25,7 @@ [![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) | ||
In short: | ||
- Define "personas" that have vocabularies which can randomly generate coherent text. | ||
- Vocabularies use keys that represent concepts, and values that represent the text to be generated. | ||
- Concepts can be cross-referenced, making for interesting and sometimes unexpected results. | ||
A persona requires a vocabulary, which defines the text that can be generated. | ||
@@ -37,7 +42,13 @@ | ||
// Here we have the greet, master, emoji, and welcome-home concepts. | ||
// Each concept maps to the text that's to be generated. | ||
// The syntax used for the values is just mustache.js. | ||
let dogVocab = { | ||
greet: "{{#choose}}woof|bark|sniff sniff|wag tail{{/choose}}", | ||
master: | ||
"{{#params.name}}{{#capitalize}}{{params.name}}{{/capitalize}}{{/params.name}}{{^params.name}}bringer of food{{/params.name}}", | ||
emoji: "{{#choose}}👅|🐶|🐾|💩|🐩|🐕{{/choose}}", | ||
"welcome-home": | ||
@@ -50,3 +61,3 @@ "{{#capitalize}}{{>greet}}{{/capitalize}}! Welcome home, {{>master}}! {{>emoji}}" | ||
console.log(max.articulate("welcome-home")); | ||
// Will generate text like following: | ||
// This will generate text like following: | ||
// Sniff sniff! Welcome home, bringer of food! 🐾 | ||
@@ -59,7 +70,7 @@ // Woof! Welcome home, bringer of food! 👅 | ||
console.log(max.articulate("greet")); | ||
// "woof", "bark", "sniff sniff", "wag tail" | ||
// "woof", "bark", "sniff sniff", or "wag tail" | ||
// The above is equivalent to using a partial, like so: | ||
console.log(max.articulate("{{>greet}}")); | ||
// "woof", "bark", "sniff sniff", "wag tail" | ||
// "woof", "bark", "sniff sniff", or "wag tail" | ||
@@ -75,12 +86,20 @@ // However, if you don't explicitly use a partial and it's not found, you'll see the text you provided: | ||
// You can pass parameters, too. These are referenced using: {{params.keyName}} | ||
console.log(max.articulate("{{params.keyName}}", { "blah": "heyyyooo" })); | ||
// "heyyyooo" | ||
// Params can be used in the vocab, too. Here, the master concept uses a name if provided. | ||
console.log(max.articulate("master", { "name": "justin" })); | ||
// "Justin" | ||
console.log(max.articulate("{{>master}}", { "name": "justin" })); | ||
// "Justin" | ||
// You can use your own mustache, too. Note no name was found here, so it used the default defined in the vocabulary. | ||
console.log(max.articulate("{{#capitalize}}{{>master}}{{/capitalize}}")); | ||
// And if not present, can fall back on a default using mustache.js syntax. | ||
console.log(max.articulate("master")); | ||
// "Bringer of food" | ||
// You can use your own mustache, too. Here we're using the capitalize wrapper on greet. | ||
console.log(max.articulate("{{#capitalize}}{{>greet}}{{/capitalize}}")); | ||
// "Woof", "Bark", "Sniff sniff", or "Wag tail" | ||
``` | ||
See the [mustache.js](https://github.com/janl/mustache.js/) documentation for reference on the syntax. | ||
## Function Wrappers | ||
@@ -87,0 +106,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
125
78333
20