use code_chunker::{LateChunkingPooler, Slab};
fn main() {
let document =
"Einstein developed relativity. He became famous. The theory transformed physics.";
let chunks = vec![
Slab::new("Einstein developed relativity.", 0, 30, 0),
Slab::new(" He became famous.", 30, 48, 1),
Slab::new(" The theory transformed physics.", 48, 80, 2),
];
let dim = 4;
let n_tokens = 16;
let token_embeddings: Vec<Vec<f32>> = (0..n_tokens)
.map(|i| {
let t = i as f32 / n_tokens as f32;
vec![t, 1.0 - t, (t * 2.0).sin(), (t * 3.0).cos()]
})
.collect();
let pooler = LateChunkingPooler::new(dim);
let chunk_embeddings = pooler.pool(&token_embeddings, &chunks, document.len());
for (chunk, emb) in chunks.iter().zip(&chunk_embeddings) {
println!("chunk {}: {:?}", chunk.index, chunk.text);
println!(" embedding: {:?}\n", emb);
}
}