Expand description
Text fingerprints: canonicalisation, word-3-shingles and a 128-word MinHash signature (design spec §4, tier-2 text lane).
Part of the pith suite: every crate in the suite builds without a
single registry package.
§Pipeline
canonicalize: NFC (viapith_unicode::nfc) → lowercase → strip trailing whitespace → exactly one'\n'.- Words =
split_whitespaceruns of the canonical text; combining marks stay attached to their base letter (accents are kept — stripping them would erase distinctions Vietnamese relies on). - Shingles = consecutive
k-word windows,k = min(3, n)for ann-word document; hashed with FNV-1a 64 over the words joined by a single ASCII space. signature= 128-word MinHash: permutationidrawsseed_ifromSplitMix64::new(SEED_STREAM)and each signature word ismin over shingles of sm64_mix(fnv1a64(shingle) ^ seed_i), wheresm64_mixis the splitmix64 output function applied as a pure finalizer (spec §4:splitmix64(FNV1a64(w) ^ seed_i)).
The crate is no_std: only alloc containers and core string
operations are used, so the same code runs on embedded targets. The
std feature (on by default) links std so the cdylib the
language SDKs bind through carries a panic handler.
Modules§
- ffi
- The C ABI surface of
pith-text: the entry points the Python (ctypes), Node (koffi) and Go (cgo) SDKs bind through. - reference
- The canonical serialization the
reference.jsonvectors are defined over — the single source of truth shared by the vector generator (crate::referenceconsumers,tools/gen-reference) and the FFI surface (crate::ffi).
Constants§
- SIGNATURE_
WORDS - Length of a
signatureinu64words.
Functions§
- canonicalize
- Canonicalises
inputfor fingerprinting. - jaccard_
estimate - Estimates the Jaccard index of the two shingle sets that produced
aandb: the fraction of equal signature words, returned as anf64in[0.0, 1.0]. - signature
- The 128-word MinHash signature of
input.