Intent recognition for prg-chatbot
npm install keyworderPredict user intents with cool machine learning tool, Facebook FastText.
1. Install Facebook FastText
2. Follow instructions
Usage
``javascript
const { Router } = require('prg-chatbot');
const keyworder = require('keyworder');
const path = require('path');
keyworder.setResolver({
model: path.join(process.cwd(), 'models', 'model.bin')
});
const app = new Router();
app.use(keyworder('hello'), (req, res, postBack, next) => {
res.text('Hello too!');
});
`
-----------------
functionCreate resolver middleware for PrgChatbot
Promise.<{tag:string, score:number}>Resolve single text
ObjectfunctionKind: global function
| Param | Type | Description |
| --- | --- | --- |
| tag | string | tag for matching |
| [threshold] | number | override success threshold |
| [namespace] | string | resolver namespace |
Example
`javascript
const keyworder = require('keyworder');
router.use(keyworder('hello-intent'), (req, res) => {
res.text('Welcome too!');
});
`
| Param | Type | Description |
| --- | --- | --- |
| configuration | Configuration | the resolver configuration |
| [namespace] | string | set resolver for diferent namespace |
Example
`javascript
const keyworder = require('keyworder');
const path = require('path');
keyworder.setResolver({
model: path.join(__dirname, 'model.bin')
});
``
Promise.<{tag:string, score:number}>Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| text | string | query text |
| [threshold] | number | override the threshold |
| [namespace] | string | use other than default resolver |
Object| Name | Type | Description |
| --- | --- | --- |
| model | string | path to trained fast text model |
| threshold | number | prediction threshold (0.95 recommended) |
| cacheSize | number | keep this amount of results cached |
| filter | function | text preprocessor |
| logger | function | resolver logger function |