0.1.0 • Published 7 years ago

keyworder v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Keyworder - Intent prediction form PrgChatbot

Predict user intents with cool machine learning tool, Facebook FastText.

Preparing the model

  1. Install Facebook FastText
  2. Follow instructions

Using with Prg-Chatbot

Usage

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!');
});

API

Functions

Typedefs

keyworder(tag, threshold, namespace) ⇒ function

Create resolver middleware for PrgChatbot

Kind: global function

ParamTypeDescription
tagstringtag for matching
thresholdnumberoverride success threshold
namespacestringresolver namespace

Example

const keyworder = require('keyworder');

router.use(keyworder('hello-intent'), (req, res) => {
    res.text('Welcome too!');
});

setResolver(configuration, namespace)

Kind: global function

ParamTypeDescription
configurationConfigurationthe resolver configuration
namespacestringset resolver for diferent namespace

Example

const keyworder = require('keyworder');
const path = require('path');

keyworder.setResolver({
    model: path.join(__dirname, 'model.bin')
});

resolve(text, threshold, namespace) ⇒ Promise.<{tag:string, score:number}>

Resolve single text

Kind: global function

ParamTypeDescription
textstringquery text
thresholdnumberoverride the threshold
namespacestringuse other than default resolver

Configuration : Object

Kind: global typedef
Properties

NameTypeDescription
modelstringpath to trained fast text model
thresholdnumberprediction threshold (0.95 recommended)
cacheSizenumberkeep this amount of results cached
filterfunctiontext preprocessor
loggerfunctionresolver logger function