Code Monkey home page Code Monkey logo

keyworder's Introduction

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

keyworder(tag, [threshold], [namespace])function

Create resolver middleware for PrgChatbot

setResolver(configuration, [namespace])
resolve(text, [threshold], [namespace])Promise.<{tag:string, score:number}>

Resolve single text

Typedefs

Configuration : Object

keyworder(tag, [threshold], [namespace]) ⇒ function

Create resolver middleware for PrgChatbot

Kind: global function

Param Type Description
tag string tag for matching
[threshold] number override success threshold
[namespace] string resolver namespace

Example

const keyworder = require('keyworder');

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

setResolver(configuration, [namespace])

Kind: global function

Param Type Description
configuration Configuration the resolver configuration
[namespace] string set 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

Param Type Description
text string query text
[threshold] number override the threshold
[namespace] string use other than default resolver

Configuration : Object

Kind: global typedef
Properties

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

keyworder's People

Contributors

davidmenger avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.