ynlu

0.5.3 • Public • Published

yoctol-nlu-node

Yoctol Natural Language Understanding SDK for Node.js

Install

$ npm install ynlu

or using yarn:

$ yarn add ynlu

Usage

const { Client } = require('ynlu');
 
// put your token into client
const client = Client.connect(process.env.TOKEN);
 
async function train() {
  const classifier = client.findClassifierById('...');
  const result = await classifier.train();
}
 
async function predict() {
  const classifier = client.findClassifierById('...');
  // the second parameter is Boolean, represent exactly match or not
  // default to true
  const result1 = await classifier.predict('買給我好不好'); // exactly match = true
  const result2 = await classifier.predict('買給我好不好', true);
  const result3 = await classifier.predict('買給我好嗎', false);
}
 
async function extract() {
  const extractor = client.findExtractorById('...');
 
  const entities = await extractor.extract('買給我好不好');
}

Options

Customize endpoint

const { Client } = require('ynlu');
 
const client = Client.connect(
  process.env.TOKEN,
  { endpoint: 'https://some.domain/graphql' }
);

/ynlu/

    Package Sidebar

    Install

    npm i ynlu

    Weekly Downloads

    33

    Version

    0.5.3

    License

    MIT

    Unpacked Size

    11.3 kB

    Total Files

    18

    Last publish

    Collaborators

    • link515