1.0.2 • Published 5 years ago

@caijs/nlg v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

@caijs/nlg

Build Status Coverage Status NPM version NPM downloads

@caijs/nlg allow to use declare answers for locales and intents, and retreive a random answer from all that are valid taking account the conditions. Also, the answer will be renderer based on the context and in the option lists.

Installation

In your project folder run:

$ npm install @caijs/nlg

Examples of use

You can evaluate an string

const { Container } = require('@caijs/container');
const evaluator = require('@caijs/eval');
const template = require('@caijs/template');
const Nlg = require('@caijs/nlg');

const container = new Container();
container.use(evaluator);
container.use(template);
const nlg = new Nlg({ container });
nlg.add('en','hello','Hello {{ name }} I will eat (melon|orange|apple)', 'type === "eat"');
nlg.add('en', 'hello', 'Hello {{ name }} I will drink (juice|water)','type === "drink"');
const answer = nlg.getAnswer('en', 'hello', { name: 'John', type: 'drink' });
console.log(answer); 
// It will return one of those two: "Hello John I will drink juice" or "Hello John I will drink water"