wit-router
A router for wit.ai entities. Rranks a set of entities returned from wit.ai based on criteria that you register.
Last updated 4 years ago by ccondry .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install wit-router 
SYNC missed versions from official npm registry.

wit-router

A router for wit.ai entities. Ranks a set of entities returned from wit.ai based on criteria that you register. Ranking is determined by averaging the 2 ranks for each comparison - how the route request entity set matched against each registered route, and how the registered route matched against the query. This favors matching more specific entity sets in the query rather than simply satisfying 100% of the match criteria of a route, so that a more specific route can be chosen instead of a simpler/less complete route.

Usage

const WitRouter = require('wit-router')
const witRouter = new WitRouter()
witRouter.register({
  name: 'version',
  entities: {
    intent: [{
      match: /^version$/
    }]
  },
  callback: function () {
    console.log('hit version route')
  }
})

witRouter.register({
  name: 'version',
  entities: {
    intent: [{
      match: /^version$/
    }],
    server: [{
      match: /^CVP$/
    }]
  },
  callback: function () {
    console.log('hit CVP version route')
  }
})

witRouter.register({
  name: 'version',
  entities: {
    intent: [{
      match: /^version$/
    }],
    server: [{
      match: /^CVP$/
    }],
    service: [{
      match: /^Call Server$/,
      required: true
    }]
  },
  callback: function () {
    console.log('hit CVP Call Server version route')
  }
})

// route to 'CVP Call Server Version'
witRouter.route({
  service: [{
    confidence: 0.90813538787052,
    value: 'Call Server',
    type: 'value'
  }],
  server: [{
    confidence: 0.93483557193052,
    value: 'CVP',
    type: 'value'
  }],
  intent: [{
    confidence: 0.99982729131181,
    value: 'version'
  }]
}).callback()

// route to 'CVP Version'
witRouter.route({
  server: [{
    confidence: 0.93483557193052,
    value: 'CVP',
    type: 'value'
  }],
  intent: [{
    confidence: 0.99982729131181,
    value: 'version'
  }]
}).callback()

// route to 'version'
witRouter.route({
  intent: [{
    confidence: 0.9884404035283,
    value: 'version'
  }]
}).callback()

Current Tags

  • 0.1.2                                ...           latest (4 years ago)

2 Versions

  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2021 © npmmirror.com |