Getting started
Fingerprint text. Compare similarity in one call.
Glyph builds MinHash signatures from text. You use Create() to fingerprint, then Compare() to score overlap.
Install
Section titled “Install”npm install @koda.oss/glyphNode.js 18 or newer is required.
First compare
Section titled “First compare”import { Create, Compare } from "@koda.oss/glyph";
const a = Create("the quick brown fox jumps over the lazy dog");const b = Create("the quick brown fox leaped over the lazy dog");
const { similarity, distance, matches, size } = Compare(a, b);| Field | Range / type | Meaning |
|---|---|---|
similarity |
0–1 |
Estimated Jaccard similarity |
matches |
integer | Matching signature slots |
distance |
integer | size - matches |
size |
integer | Signature length |
Mental model
Section titled “Mental model”- Tokenize input text into words.
- Build a feature bag: tokens, unigrams, vgrams.
- Run bag MinHash to produce a
Uint32Array(glyph). - Compare glyphs by counting equal slots.
Identical normalized text gives similarity: 1. Unrelated text is near 0.
What Create returns
Section titled “What Create returns”{ "version": 1, "glyph": "<Uint32Array>", "createdAt": 1710000000000}version— create pipeline version.glyph— the fingerprint bytes.createdAt— milliseconds since epoch (changes each call).
You can pass a full record or record.glyph into Compare and Serialize.