Skip to content

Create

Turn text into a glyph record with Create().

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

import { Create } from "@koda.oss/glyph";
const record = Create("hello world", {
size: 128,
vgramSize: 4,
normalize: true,
});
Option Default Meaning
size 128 Number of MinHash slots
vgramSize 4 Word n-gram width for vgrams
normalize true Apply 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).

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)
Stage Helper Doc
Tokens CreateTokens Tokenize
Unigrams unigrams from tokens Tokenize
Vgrams vgrams from tokens Tokenize
{
"version": 1,
"glyph": "<Uint32Array length = size>",
"createdAt": 1710000000000
}

version is the create pipeline version (currently 1).

Condition Result
size < 1 Throws
vgramSize < 1 Throws