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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rebelstack-io/intent

v1.0.0

Published

Modern TypeScript ESM intent classification and entity extraction.

Readme

@rebelstack-io/intent

Modern TypeScript and native ESM intent classification and entity extraction, inspired by a minimized subset of node-nlp.

This package focuses on:

  • intent classification
  • entity extraction
  • synonym-style entity option mapping
  • number extraction
  • confidence scores
  • model training
  • JSON model import/export

It intentionally does not include chatbot dialogs, response generation, actions, sentiment analysis, servers, connectors, Excel import, speech features, LLM integrations, or filesystem-based model loading.

Runtime

The package targets modern Node.js and native ESM.

import { NlpManager } from "@rebelstack-io/intent";

Core source avoids required filesystem access and Node-only runtime APIs. Browser use is expected to go through the consumer's bundler.

Basic Usage

import { NlpManager } from "@rebelstack-io/intent";

const manager = new NlpManager();

manager.addDocument("en", "fire the missiles", "attack.fire");
manager.addDocument("en", "launch missiles", "attack.fire");
manager.addDocument("en", "hold position", "defense.hold");
manager.addDocument("en", "stay where you are", "defense.hold");

await manager.train();

const result = await manager.classify("en", "please launch the missile");

console.log(result.intent);
console.log(result.score);
console.log(result.classifications);

Classification results include the winning intent, its score, and ranked classifications.

Entity Extraction

Enum entities map one or more source texts to a shared option.

const manager = new NlpManager();

manager.addNamedEntityText("weapon", "missile", "en", [
  "missile",
  "rocket"
]);

const entities = await manager.extractEntities("en", "launch the rocket");

console.log(entities[0]?.entity); // "weapon"
console.log(entities[0]?.option); // "missile"

Regex entities are supported:

manager.addRegexEntity("order", "en", /ORD-\d+/iu);

Trim entities are supported with before, after, and between conditions:

manager.addBetweenCondition("target", "en", "target", "now");

Number Extraction

Numbers are extracted as the built-in number entity.

const entities = await manager.extractEntities(
  "en",
  "load twenty one missiles"
);

console.log(entities[0]?.resolution?.value); // 21

Supported number scope:

  • digit integers
  • digit decimals
  • signed digit numbers where unambiguous
  • English cardinal numbers
  • basic Spanish cardinal numbers

High-Level Processing

process() combines classification and entity extraction. Entity placeholders in training utterances act as slot metadata.

const manager = new NlpManager();

manager.addDocument("en", "fire %weapon%", "attack.fire");
manager.addNamedEntityText("weapon", "missile", "en", "missile");

await manager.train();

const result = await manager.process("en", "fire missile");

console.log(result.intent); // "attack.fire"
console.log(result.entities);

By default, process() extracts entities for the winning intent's slots. Pass { forceNER: true } to extract all matching entities.

Model Export and Import

Models are JSON-compatible objects or strings. Runtime consumers do not need to retrain after import.

const exported = manager.export(true);

const fresh = new NlpManager();
fresh.import(exported);

const result = await fresh.classify("en", "launch missiles");

Object hooks are also available:

const model = manager.toObj();
fresh.fromObj(model);

The minimized model format records classifier backend identity and retained NLU, NER, and slot metadata. Unsupported upstream-style top-level sections such as NLG and actions are ignored when the retained sections are structurally compatible.

Classifier Backends

Two classifier backends are available:

  • neural: the default backend, intended for stronger classification quality as corpora become less keyword-like.
  • bayes: a compact probabilistic backend, useful for small corpora, fast training, and deterministic baseline behavior.

Select a backend explicitly:

const neural = new NlpManager({ classifier: "neural" });
const bayes = new NlpManager({ classifier: "bayes" });

Both backends support training, classification, export, and import without retraining.

Language Support

Supported base locales:

  • en
  • es

Accepted aliases include en-US, en-GB, es-ES, es-MX, and other unambiguous Spanish regional aliases registered by the package.

Unsupported locales throw clear errors:

manager.addDocument("fr", "bonjour", "greeting.hello");
// Error: Unsupported locale: fr

Language support is intentionally added deliberately rather than through a broad language bundle.

Differences From node-nlp

This package is a retained subset, not a full port of node-nlp.

Intentional differences:

  • Native ESM only.
  • TypeScript source only.
  • Modern Node.js target only.
  • No CommonJS build.
  • No service container or dynamic pipeline clone.
  • No required filesystem model IO.
  • No NLG, action manager, sentiment, dialog, bot, server, connector, Excel, speech, or LLM subsystems.
  • Model compatibility is tolerant for retained structures, but full upstream model compatibility is not a goal.
  • Language support is currently English and Spanish only.
  • Built-in entity extraction is intentionally limited to focused local number extraction.

The public API keeps the retained NlpManager workflow where practical: addDocument, removeDocument, train, classify, process, extractEntities, entity registration helpers, toObj, fromObj, export, and import.

Development

Tests use Node's built-in test harness.

npm run typecheck
npm test
npm run test:tsx
npm run build