Expand description
The core tokenizer, v2.
The tokenizer is deliberately split into four stages:
- NFKC normalization of the input;
- UAX #29 word segmentation and CJK adjacency tracking;
- policy-driven Unicode folding;
- canonical, byte-budgeted token emission.
The stages share caller-owned scratch buffers, so the ordinary Latin, Cyrillic, and generic-script paths remain allocation-free after warm-up and behave identically on native and WASM. ICU4X’s dictionary/LSTM path for complex scripts may allocate inside its iterator, but uses the same token policy and canonical emission rules. Emitted tokens are canonical fixed points of the tokenizer.
Structs§
- Tokenizer
- Streaming tokenizer with reusable scratch buffers.
- Tokenizer
Policy - Controls search-specific folding without changing the scanner or its allocation behavior.
Constants§
- MAX_
TOKEN_ BYTES - Upper bound on an emitted token, in bytes.