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

@liquidau/rule-miner

v0.5.3

Published

Mine high-precision, human-readable rules from labelled text and compile them to linear-time regex: group-aware sequential covering with stopword and background-corpus filters, validation and evaluation, and a validated rule-set artifact for runtime.

Downloads

1,009

Readme

@liquidau/rule-miner

Learns short phrase rules from labelled text, checks how often they fire on ordinary text, and compiles them to linear-time regex.

labelled text + ordinary background text
        │
        ▼
mineRules ──► validateRules ──► certify* ──► buildRuleSet ──► ruleSetMatcher
   ▲                                                                │
   │                                                                ▼
accepted / rejected ◄────────── human review ◄──────── firingReport, diffRuleSets

certify*:       certifyFalseAlarms (≤ r of labelled negatives, 95%), or
                certifyPrefixes (fires on ≤ r of unlabelled traffic, 95%)
mineExceptions: "fire unless…" for any existing rule, including hand-written regex
weakLabels:     rule hits as weighted training data for @liquidau/embedding-classifier

Uses @liquidau/solvers for exact bounds; pair it with @liquidau/embedding-classifier for recall.

Install

npm install @liquidau/rule-miner

Example

import { buildRuleSet, certifyPrefixes, hitMatrix, mineRules, ruleSetMatcher } from '@liquidau/rule-miner';

// Labelled examples (1 = refund request) and ordinary traffic to veto rules that fire on it.
const texts = ['I want a full refund', 'please give me a full refund now', 'can I get a full refund?', 'where is my parcel', 'thanks for the help', 'how do I change my address'];
const y: (0 | 1)[] = [1, 1, 1, 0, 0, 0];
const background = ['what time do you open', 'my parcel is late again', 'thanks, all sorted'];

const rules = mineRules({ texts, y, background }, { minGroups: 3 });
// Certify on held-out ordinary traffic. Use thousands of texts and a rate like 0.002 in practice.
const heldOut = ['is the shop open on sunday', 'I love this store', 'how much is delivery', 'can I pay by card'];
const cert = certifyPrefixes(hitMatrix(rules, heldOut), { maxRate: 0.6 });
const set = buildRuleSet('2026-10-03', [{ label: 'refund', rules: rules.slice(0, cert.certified) }]);
console.log(ruleSetMatcher(set).match('I demand a full refund')); // { id: 'refund.r1', label: 'refund' }

What's in it

| Area | Exports | |---|---| | Mining | mineRules, validateRules | | Exceptions | mineExceptions, withExceptions | | Word variants | Lexicon (replacements, optional Porter stemming, classes), induceClasses, porterStem | | Stress test | stressTest, ruleStressItems, exceptionStressItems | | Certification | certifyFalseAlarms, certifyPrefixes, precisionLowerBound | | Weak labels | ruleBounds, weakLabels, disagreementQueues | | Rule sets | buildRuleSet, validateRuleSet, ruleSetMatcher, diffRuleSets, firingReport | | Hard negatives, background | hardNegativeItems, checkBackgroundRecords |

Guarantees and limits

  • Regexes are re-derived from patterns on load, so matching runs in linear time.
  • Certification is an exact 95% bound on false alarms (labelled negatives) or firing rate (traffic).
  • The stress test gates exceptions only, never rules.
  • Expect high precision, low recall (held out: 11 of 140 positives per head); pair with a classifier.
  • Runs on Node 22.18+ and on edge and browser runtimes (no Node built-ins).

More

Develop

nvm use         # Node 22 (.nvmrc); 22.18+ runs .ts directly
npm install
npm test        # node --test on the .ts sources, no build or loader
npm run build   # dist/ (ESM + .d.ts)

License

MIT. See LICENSE.

Third-party code

src/stem.ts is adapted from stemmer 2.0.1 by Titus Wormer (MIT); its notice is kept in the file.