ecrmnn / wit-keywords

Mass push values to keyword based entities on Wit.ai

Home Page:https://npmjs.com/wit-keywords

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wit-keywords

Mass push values to keyword based entities on Wit.ai

Travis npm version npm downloads npm license

Installation

npm install wit-keywords --save

Usage

Push an array of actors to the actor entity

const keywords = require('wit-keywords');

new keywords(process.env.WIT_TOKEN)
  .entity('actor')
  .push([
    'Leonardo DiCaprio',
    'Steve Carell',
    'Alec Baldwin',
    'Micheal Cera'
  ])
  .then(response => console.log(response))
  .catch(err => console.log(err));

//=> [{
//=>   value: 'Leonardo DiCaprio',
//=>   status: 'added'
//=> }, {}, {}, {}]

Trigger a function after each pushed item

const keywords = require('wit-keywords');

new keywords(process.env.WIT_TOKEN)
 .entity('actor')
 .after(actor => {
   // Do something
 })
 .push([
   'Leonardo DiCaprio',
   'Steve Carell',
   'Alec Baldwin',
   'Micheal Cera'
 ]);

Trigger a function after each pushed item

const keywords = require('wit-keywords');

new keywords(process.env.WIT_TOKEN)
  .entity('actor')
  .after(actor => {
    // Do something
  })
  .push([
    'Leonardo DiCaprio',
    'Steve Carell',
    'Alec Baldwin',
    'Micheal Cera'
  ]);

Set custom number of parallel requests (concurrency)

const keywords = require('wit-keywords');

new keywords(process.env.WIT_TOKEN)
  .concurrency(4) // Default = 3
  .entity('actor')
  .after(actor => {
    // Do something
  })
  .push([
    'Leonardo DiCaprio',
    'Steve Carell',
    'Alec Baldwin',
    'Micheal Cera'
  ]);

License

MIT © Daniel Eckermann

About

Mass push values to keyword based entities on Wit.ai

https://npmjs.com/wit-keywords

License:MIT License


Languages

Language:JavaScript 100.0%