Skip to content

CAI-js/nlg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published