Skip to content

@studnicky/matching ​

@studnicky/matching supplies independent deterministic tools. A caller chooses whether to normalize text, create a candidate pool, score a candidate pair, or test a structural pattern; the package does not turn those choices into a prescribed pipeline.

GlobMatcher supports standard *, **, ?, character-class, and brace-alternative glob syntax through a browser-compatible implementation. TrieMatcher compiles one segment pattern for repeated evaluation, while TreeMatcher and the candidate-index classes own mutable registration and candidate materialization.

The semantic subpaths define provider-neutral vectorization, vector-index, reranking, classification, and adjudication contracts. They own JSON intake models and asynchronous boundary contracts only; callers supply their own provider, model, index, ranking policy, and orchestration.

Northstar Books catalogue matching ​

A reader who searches for a title by a misspelled name, partial ISBN, or alternate spelling still needs a catalogue result that the server can explain and reproduce. Northstar normalizes the query, materializes candidates, then chooses its scoring policy with these primitives. The package guarantees deterministic normalization, candidate materialization, matching, and score evidence; the application retains control of thresholds, ranking policy, and the surrounding search workflow.

Install ​

bash
pnpm add @studnicky/matching

Try it ​

A Northstar Books reader who types "clean code" with stray spaces and imperfect memory still expects the catalogue to find "Clean Code" — not nothing, and not the wrong book. The example below normalizes that query, pulls a short list of plausible titles out of an n-gram candidate index seeded with three programming classics, then scores each candidate against the query with deterministic edit-distance similarity. The result: "Clean Code" comes back on top with a similarity score above 0.8, giving Northstar Books reproducible evidence it can rank on rather than a black-box guess.

Loading example…
Loading example…
Loading example…

What it is ​

@studnicky/matching is a set of deterministic text, candidate-selection, and semantic-boundary primitives. It provides small pieces that can be composed into a catalogue search or review flow; it does not provide a search product, ranking policy, provider, or workflow.

What it is for ​

Northstar Books uses these primitives when it needs reproducible catalogue matching: normalize a reader’s query, materialize plausible book records, score a pair of titles or identifiers, or define the contract around an embedding, reranking, classification, or adjudication provider. Browser and Node entrypoints expose the same runtime-safe primitives; semantic entities and interfaces define validated inputs and provider contracts rather than another application layer.

Northstar Books examples ​

  • Normalize, retrieve candidates, and score similar text solves the “reader typed a title imperfectly” problem. It normalizes the submitted title, finds plausible catalogue records, and produces deterministic score evidence that Northstar can use in its own ranking decision.
  • Validate a provider classification at the boundary solves the “a supplier or AI service labelled an incoming book record” problem. It validates the received classification before Northstar’s inventory workflow consumes it, proving that provider output enters the application through a defined contract.
  • Compose a vectorizer with a local vector index solves the “find conceptually related books” problem. It connects a vectorizer and index through the public contracts, proving that Northstar can choose its own embedding provider and storage while retaining a portable search boundary.

Public entrypoints ​

Import pathUse it when
@studnicky/matching/nodeNorthstar runs deterministic candidate, encoding, extraction, matcher, normalization, and scoring primitives in its Node catalogue service.
@studnicky/matching/browserNorthstar runs the same browser-safe primitives in a reader-facing catalogue experience.
@studnicky/matching/candidate-sourcesNorthstar materializes a bounded set of plausible book identifiers before applying its chosen score or ranking policy.
@studnicky/matching/encodersNorthstar derives phonetic, sparse, or set-similarity representations for titles, authors, and ISBN-adjacent search terms.
@studnicky/matching/extractorsNorthstar extracts tokens or character n-grams from catalogue text before matching it.
@studnicky/matching/matchersNorthstar tests title, collection, or shelving strings against exact, structural, prefix, suffix, or glob patterns.
@studnicky/matching/normalizersNorthstar canonicalizes a reader query or imported catalogue field at the intake boundary before comparison.
@studnicky/matching/scorersNorthstar selects a deterministic similarity measure and receives score evidence for a candidate pair.
@studnicky/matching/interfacesNorthstar types its own candidate set, selection, and match-evidence implementations without coupling to a product implementation.
@studnicky/matching/semantic/nodeNorthstar composes provider-neutral semantic contracts with Node-side provider or index adapters.
@studnicky/matching/semantic/browserNorthstar composes browser-safe semantic contracts where the reader experience needs them.
@studnicky/matching/semantic/entitiesNorthstar validates vector, reranking, classification, and adjudication inputs at the boundary before consuming provider data.
@studnicky/matching/semantic/interfacesNorthstar implements or injects vectorizer, vector-index, reranker, classifier, and adjudicator contracts without selecting a provider in the package.

Exports ​

SymbolPurposeImport path
BloomCandidateFilterProbabilistic membership prefilter with false-positive evidence.@studnicky/matching/node
CandidateSetInterfaceDefines a materialized candidate identifier set.@studnicky/matching/interfaces
CuckooCandidateFilterDeletable probabilistic membership prefilter.@studnicky/matching/node
LshCandidateIndexLocality-sensitive candidate materialization index.@studnicky/matching/node
NgramCandidateIndexCandidate index keyed by character n-grams.@studnicky/matching/node
DoubleMetaphoneEncoderPrimary and alternate phonetic encoding.@studnicky/matching/node
MetaphoneEncoderDeterministic phonetic encoding.@studnicky/matching/node
MinimumHashEncoderFixed-seed approximate set-similarity signature.@studnicky/matching/node
MatchEvidenceInterfaceDefines deterministic match evidence for a candidate.@studnicky/matching/interfaces
SoundexEncoderEnglish phonetic encoding.@studnicky/matching/node
TfIdfEncoderSparse TF-IDF vector encoder.@studnicky/matching/node
NgramExtractorCharacter n-gram extraction.@studnicky/matching/node
TokenExtractorToken extraction.@studnicky/matching/node
AhoCorasickMatcherLiteral substring matching with an Aho–Corasick automaton.@studnicky/matching/node
ExactMatcherExact value matching.@studnicky/matching/node
GlobMatcherGlob pattern matching.@studnicky/matching/node
RadixMatcherPrefix-compressed structural pattern matching.@studnicky/matching/node
SuffixMatcherBoyer–Moore-style suffix matching.@studnicky/matching/node
TreeMatcherHierarchical structural matching.@studnicky/matching/node
TrieMatcherSegment-trie structural matching.@studnicky/matching/node
StringNormalizerBoundary string canonicalization.@studnicky/matching/node
CosineScorerSparse-vector cosine similarity.@studnicky/matching/node
DamerauLevenshteinScorerTransposition-aware edit-distance similarity.@studnicky/matching/node
JaccardScorerSet overlap similarity.@studnicky/matching/node
JaroScorerShort-string similarity.@studnicky/matching/node
JaroWinklerScorerPrefix-weighted short-string similarity.@studnicky/matching/node
LevenshteinScorerEdit-distance similarity.@studnicky/matching/node
NgramScorerCharacter n-gram similarity.@studnicky/matching/node
SorensenDiceScorerSet overlap similarity.@studnicky/matching/node
MatchingAllocationErrorThrown when a scorer cannot allocate working memory for an input pair; the platform error is the cause (matching.allocationFailed).@studnicky/matching/node
ScoreEvidenceInterfaceDefines a score and its deterministic evidence.@studnicky/matching/interfaces
SelectionInterfaceDefines a selected candidate and score.@studnicky/matching/interfaces
AdjudicationEntityValidates an adjudication confidence result.@studnicky/matching/semantic/entities
AdjudicationInputEntityValidates content and candidate identifiers for adjudication.@studnicky/matching/semantic/entities
ClassificationEntityValidates a classification label and confidence.@studnicky/matching/semantic/entities
ClassificationInputEntityValidates classification content and optional labels.@studnicky/matching/semantic/entities
RerankInputEntityValidates content and candidate identifiers for reranking.@studnicky/matching/semantic/entities
RerankMatchEntityValidates a reranked identifier and score.@studnicky/matching/semantic/entities
VectorEntryDataEntityValidates a vector entry identifier and namespace.@studnicky/matching/semantic/entities
VectorMatchEntityValidates a vector-search identifier and score.@studnicky/matching/semantic/entities
VectorSearchOptionsEntityValidates vector-search namespace and limit.@studnicky/matching/semantic/entities
VectorizationInputEntityValidates content and metadata before embedding.@studnicky/matching/semantic/entities
AdjudicatorInterfaceDefines asynchronous provider-neutral adjudication.@studnicky/matching/semantic/interfaces
ClassifierInterfaceDefines asynchronous provider-neutral classification.@studnicky/matching/semantic/interfaces
RerankerInterfaceDefines asynchronous provider-neutral reranking.@studnicky/matching/semantic/interfaces
VectorEntryInterfaceDefines a vector payload with canonical entry data.@studnicky/matching/semantic/interfaces
VectorIndexInterfaceDefines asynchronous vector index storage and search.@studnicky/matching/semantic/interfaces
VectorizerInterfaceDefines asynchronous embedding production.@studnicky/matching/semantic/interfaces

Each category is also available from its named subpath: candidate-sources, encoders, extractors, matchers, normalizers, and scorers.

Source on GitHub