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

@andorsearch/significant-terms

v0.5.1

Published

A TypeScript library with significant term scoring heuristics based on Elastic/OpenSearch.

Downloads

6

Readme

@andorsearch/significant-terms

Docs

A set of Elastic/OpenSearch-inspired significance scoring heuristics for discovery of terms strongly related to a set.

Typically the point of identifying significant terms is to suggest terms users can use to refine searches.

Watch this for background on the signficance statistics.

"Significant compared to what"?

These algorithms rely on comparing a focused set of data (the "foreground set") with a larger set of more general content (the "background set"). The sources of data generally fall into two camps:

1) Word usage in search results

The words used in a specific set of search results are compared with a cache of word usage statistics which have been taken from a much broader selection of content. While elasticsearch and opensearch implementations compare search results with the full database (often at some expense), it is possible for client applications to hold a much smaller cache of only the most common words as the background dataset. This small background set can be less than one megabyte of JSON and still be useful.

2) Labelling clusters of similar content

A set of content eg the latest news headlines are grouped into different clusters (e.g. by using binary vectors). The words used in each cluster are compared to word usage in all other clusters to help identify what makes it different.

Heuristics Included

  • JLH
  • Chi-Square
  • Mutual Information
  • Google Normalized Distance (GND)
  • Percentage Score
  • Solr Relatednesss

Low-level usage

import { getHeuristic } from "@andorsearch/significance-heuristics";

const jlh = getHeuristic("jlh");
const score = jlh.score(12, 100, 40, 1700000);

Each heuristic implements:

interface SignificanceHeuristic {
  name: string;
  score(subsetFreq: number, subsetSize: number, supersetFreq: number, supersetSize: number): number;
}

Usage with search results

Significant keywords can be detected in search results. These can be shown as suggestions to refine queries e.g to add keyword "h5n1" to a search for "bird flu".

The language used in search results needs to be compared with some record of general word use we call "the background". A background is simply a list of words and how frequently they each occur. You can get a background of word use from a couple of places:

  • Download a pre-built background e.g. this English background or
  • Generate your own background
    • From text The significant terms package contains a utility to count the words in a text file
      npx @andorsearch/significant-terms count-background-vocab 'MyExampleTextFile.txt' MyBackgroundWordStats.json
      ``` **or**
    • From your elasticsearch/opensearch index: run a version of this query to generate a list of words from a randomised selection of content in your choice of index/field.

Once you have a background it can be used for comparison with search results:

import { computeSignificantTerms, detectAndSortSequences, simpleTokenizer, WordUsageCounts } from "@andorsearch/significant-terms";

// ==== Your choice of background ====
// const backgroundWordStats:WordUsageCounts
// const backgroundCorpusSize:number

function findSignificantWordsOrPhrases(searchResultTexts: string[]) {
    // Tokenise the text found in search results
    let tokenStreams = searchResultTexts.map((textValue) => simpleTokenizer(textValue))

    //Find the significant words compared to the background
    const significantWords = computeSignificantTerms(
        tokenStreams,
        backgroundWordStats,
        backgroundCorpusSize
    );
    // Optionally, examine how the significant words are placed in the text to identify word pairs e.g. "Mitt" + "Romney"
    let significantWordsOrPhrases = detectAndSortSequences(significantWords, tokenStreams)

    // Display the words or phrases as a comma delimited list.
    const summary = significantWordsOrPhrases.map(termOrPhrase => termOrPhrase.join(" ")).join(", ");
    console.log(summary)
}```