Create

August 2, 2026 · View on GitHub

Glyph Ribbon

Create

Turn text into a glyph record with Create().

Create(text, options?) tokenizes input, builds a feature bag, and runs bag MinHash.

Usage

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

const record = Create("hello world", {
  size: 128,
  vgramSize: 4,
  normalize: true,
});

Options

OptionDefaultMeaning
size128Number of MinHash slots
vgramSize4Word n-gram width for vgrams
normalizetrueApply filter/strip pipeline

Larger size gives a more stable estimate and a larger payload. Larger vgramSize favors phrase overlap; short text may produce zero vgrams (unigrams still contribute).

Feature bag

Each glyph hashes three feature sets:

tokens   → filtered words
unigrams → stripped tokens
vgrams   → stripped overlapping word windows (width = vgramSize)

bag = [...tokens, ...unigrams, ...vgrams]
glyph = bagMinHash(bag, size)
StageHelperDoc
TokensCreateTokensTokenize
Unigramsunigrams from tokensTokenize
Vgramsvgrams from tokensTokenize

Return value

{
  "version": 1,
  "glyph": "<Uint32Array length = size>",
  "createdAt": 1710000000000
}

version is the create pipeline version (currently 1).

Errors

ConditionResult
size < 1Throws
vgramSize < 1Throws

Related links ranked by Glyph.