Compare

August 2, 2026 ยท View on GitHub

Glyph Ribbon

Compare

Score similarity between glyphs with Compare(), CompareGlyphs(), or CompareGroups().

Comparison estimates Jaccard similarity between two text feature bags by counting equal MinHash slots.

Compare(a, b, options?)

Routes automatically:

Input on either sidePath
Single glyph, signature, or recordCompareGlyphs
GlyphGroup / GlyphGroupInput (map or array)CompareGroups
import { Create, Compare } from "@koda.oss/glyph";

const a = Create("Goodbye moon");
const b = Create("Goodbye sun");

Compare(a, b);
Compare(a.glyph, b.glyph);

Accepts Glyph, GlyphSignature, GlyphRecord, or GlyphGroupInput (map or array).

CompareGlyphs(a, b, options?)

Pairwise compare only. Use when both sides are single glyphs (or signatures/records).

import { Create, CompareGlyphs } from "@koda.oss/glyph";

CompareGlyphs(Create("a"), Create("b"));

CompareGroups uses this internally for every pair.

CompareGroups(group1, group2, options?)

Explicit group compare. Scores every pair, then aggregates (default: max).

import { CreateGroup, CompareGroups } from "@koda.oss/glyph";

CompareGroups(
  CreateGroup(["alpha beta", "gamma delta"]),
  CreateGroup(["gamma delta", "unrelated"]),
);

Result: GlyphComparisonResult

{
  "similarity": 0.35,
  "matches": 45,
  "distance": 83,
  "size": 128
}
FieldMeaning
similaritymatches / size
matchesEqual signature slots
distancesize - matches
sizeSignature length

Options

interface GlyphComparisonOptions {
  aggregate?: GroupResultAggregator; // CompareGroups only
}

CompareGlyphs ignores aggregate. See Groups.

Errors

ConditionResult
Glyph size mismatchThrows
Empty groupThrows

Interpret scores

similarityTypical meaning
1.0Identical feature bags (usually identical normalized text)
HighStrong word/phrase overlap
LowLittle overlap
Near 0Unrelated

MinHash estimates set similarity. It is not edit distance or embedding cosine similarity.

Related links ranked by Glyph.