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,});Options
Section titled “Options”| 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).
Feature bag
Section titled “Feature bag”Each glyph hashes three feature sets:
tokens → filtered wordsunigrams → stripped tokensvgrams → 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 |
Return value
Section titled “Return value”{ "version": 1, "glyph": "<Uint32Array length = size>", "createdAt": 1710000000000}version is the create pipeline version (currently 1).
Errors
Section titled “Errors”| Condition | Result |
|---|---|
size < 1 |
Throws |
vgramSize < 1 |
Throws |