npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nlp-hub

v1.1.4

Published

The hub for natural language processing (nlp) engines.

Readme

nlp-hub

nlp-hub is a micro-framework that connects you to multiple natural language processing engines such as LUIS, QnA Maker Watson or even local regular expressions.

nlp-hub allows you to build lightweight chatbots aimed for scenarios with minimal context (think: question -> answer). You can use different strategies to reduce processing costs, increase reliability or improve performance, depending on your goals.

Usage

Set up the JSON definition file. Note that each provider has its own parameters.

{
    "threshold":"0.8",
    "apps":[
        {"id":"HolaRegex", "intent":"Saludo", "exp":"(^hola$|^holaa$|^holas$|^holi$|^holis$|^hi$|^hello$)", "type":"regex"},
        {"id":"ComprarVueloRegex", "intent":"ComprarVuelo", "exp":"^Comprar vuelo$", "type":"regex"},
        {"id":"5d90b68...", "key":"3f7eb1b5...", "type":"luis"},
        {"id":"3285f3b...", "key":"3f7eb1b5...", "type":"luis"},
        {"id":"QnA_BOFA_ES", "kb":"055836...", "key":"bdfa0e...", "type":"qnamaker"}
    ]
}

Then call the strategy of your choice from your code.

nlp.firstMatch(query, function(response) {
    console.log(`The first detected intent was ${response.intent.name} according to ${response.engine}`);
});

Strategies

firstMatch

Runs each app syncronously on the JSON definition file and stops after finding the first one that goes over the threshold. Use this strategy for cost-effectiveness.

nlp.firstMatch(query, function(response) {
    console.log(`The first detected intent was ${response.intent.name} according to ${response.engine}`);
});

bestMatch

Runs each app on the JSON definition file asynchronously and in parallel, computes and finds the best score. Use this strategy for reliability.

nlp.bestMatch(query, function(response) {
    console.log(`The first detected intent was ${response.intent.name} according to ${response.engine}`);
});

Engines

LUIS

To support LUIS, add an app on the apps.json definition file with the following fields:

  • id: LUIS app id
  • key: LUIS key
  • type: LUIS
[{"id":"5d90b68..", "key":"3f7eb1..", "type":"luis"}]

QnA Maker

To support QnA Maker, add an app on the apps.json definition file with the following fields:

  • id: an identification name of your choice (optional)
  • kb: the id of your knowledge base
  • key: your QnA app's key
  • type: qnamaker
[{"id":"QnA_BOFA_ES", "kb":"05583..", "key":"bdfa0ea..", "type":"qnamaker"}]

Regular expressions

To support Regular Expressions, add an app on the apps.json definition file with the following fields:

  • id: an identification name of your choice (optional)
  • intent: the intent name this regex matches
  • exp: the expression to match
  • type: regex
[{"id":"HolaRegex", "intent":"Saludo", "exp":"(^hola$|^holaa$|^holas$|^holi$|^holis$|^hi$|^hello$)", "type":"regex"},]

Usage with Microsoft Bot Framework

To integrate nlp-hub with Microsoft Bot Framework, you can simply use a root dialog to call nlp.firstMatch or any other strategy of your choice. You could also trigger different dialogs based on the user input if you wanted to.

This is an example of the simplest integration between nlp-hub and Microsoft Bot Framework.

var builder = require('botbuilder');
var nlp = require('../core/core.js');

var connector = new builder.ConsoleConnector().listen();
var bot = new builder.UniversalBot(connector);

nlp.load('../apps.json');

bot.dialog('/', [
    function (session) {
        nlp.firstMatch(session.message.text, function(response) {
            session.send(`The first detected intent was ${response.intent.name} according to ${response.engine}`);
        });
    }
]);