textkit: token counting and the two segmenters

This commit is contained in:
funkpower committed 2026-09-19 11:04:27 -04:00
1 parent 00f4c38816
commit 0208b14b5d
6 files changed
+454

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
//! Tokenising and segmenting text, the way the catena tools agree to do it.
//!
//! Two jobs, both of which have to give the same answer everywhere or chunk
//! boundaries move: counting tokens the way the embedding stack counts them,
//! and cutting text into sentences and paragraphs the way the existing
//! pipelines cut it.
//!
//! The segmenters reproduce Python's `re` semantics deliberately, down to
//! which characters count as whitespace, because their output decides where a
//! chunk ends and a chunk boundary that moves is a chunk that no longer
//! matches what is already in an index.
pub mod segment;
pub mod tokens;
pub use segment::{is_space, paragraphs, sentences};
pub use tokens::{count, decode_lossy, encode, split_at_token_limit};