Model / text · All operations
Split text into chunks
A variant of Split text into words
Cut long text into segments by size, window or boundary pattern, one row per chunk.
Status
- In arcform
Runs as a SQL step
arcform carries it as a
sql:step today.
The DuckDB step
Cut long text into chunks by size, by window and by a boundary pattern, one row per chunk
-- three texts: one of 50 characters, one shorter than a window, and one whose last sentence has no full stop
CREATE TEMP TABLE docs AS SELECT * FROM (VALUES (1, 'Ducks swim. Geese fly south. Swans glide on lakes.'), (2, 'Hi there'), (3, 'First one. Then no stop')) t(doc, body);
-- by size: consecutive pieces of 20 characters, the last one short
CREATE TEMP TABLE by_size AS
SELECT doc, 'size' AS how, i // 20 + 1 AS n, substr(body, i + 1, 20) AS chunk FROM docs, range(0, (SELECT max(length(body)) FROM docs), 20) t(i) WHERE i < length(body);
-- by window: 20 characters starting every 10, so neighbours overlap by 10; windows go on until one reaches the last character, and that one may run short
CREATE TEMP TABLE by_window AS
SELECT doc, 'window' AS how, i // 10 + 1 AS n, substr(body, i + 1, 20) AS chunk FROM docs, range(0, (SELECT max(length(body)) FROM docs), 10) t(i) WHERE i = 0 OR i + 10 < length(body);
-- by boundary pattern: each sentence ends at a full stop, and text after the last one is a piece of its own
CREATE TEMP TABLE by_pattern AS
SELECT doc, 'pattern' AS how, generate_subscripts(parts, 1) AS n, unnest(parts) AS chunk FROM (SELECT doc, regexp_extract_all(body, '\S[^.]*\.?') AS parts FROM docs);
CREATE TEMP TABLE chunks AS SELECT * FROM by_size UNION ALL SELECT * FROM by_window UNION ALL SELECT * FROM by_pattern;
SELECT * FROM chunks ORDER BY doc, how, n;
SELECT CASE WHEN ((SELECT list(chunk ORDER BY n) = ['Ducks swim. Geese fl', 'y south. Swans glide', ' on lakes.'] FROM chunks WHERE doc = 1 AND how = 'size')
AND (SELECT list(chunk ORDER BY n) = ['Ducks swim. Geese fl', '. Geese fly south. S', 'y south. Swans glide', 'wans glide on lakes.'] FROM chunks WHERE doc = 1 AND how = 'window')
AND (SELECT list(chunk ORDER BY n) = ['Ducks swim.', 'Geese fly south.', 'Swans glide on lakes.'] FROM chunks WHERE doc = 1 AND how = 'pattern')
AND (SELECT list(chunk ORDER BY how) = ['Hi there', 'Hi there', 'Hi there'] FROM chunks WHERE doc = 2)
AND (SELECT list(chunk ORDER BY n) = ['First one. Then no s', 'top'] FROM chunks WHERE doc = 3 AND how = 'size')
AND (SELECT list(chunk ORDER BY n) = ['First one. Then no s', ' Then no stop'] FROM chunks WHERE doc = 3 AND how = 'window')
AND (SELECT list(chunk ORDER BY n) = ['First one.', 'Then no stop'] FROM chunks WHERE doc = 3 AND how = 'pattern')
AND (SELECT bool_and(joined = body) FROM (SELECT d.body, string_agg(c.chunk, '' ORDER BY c.n) AS joined FROM docs d JOIN chunks c USING (doc) WHERE c.how = 'size' GROUP BY d.doc, d.body))) THEN 'as expected' ELSE error('the three texts should give 3 chunks of 20, 4 overlapping windows and 3 sentences for the long one, the whole short text in each form, and the unterminated last sentence kept, with the size chunks joining back into every text') END AS verdict;- The statement builds its own data.
- It needs nothing installed beyond DuckDB itself.
- The statement checks its own result and raises an error when it is wrong: “the three texts should give 3 chunks of 20, 4 overlapping windows and 3 sentences for the long one, the whole short text in each form, and the unterminated last sentence kept, with the size chunks joining back into every text”.
- It passed on DuckDB
v2.0.0 (Cyanoptera) d54cbbe3df.
What other tools call it
Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).
Apache Hop (1)
Text chunkerread 2026-09-27Split text into chunks for embedding without breaking words or sentences
Duckle (1)
Text Chunkerread 2026-09-25split long text into overlapping character-window chunks
RapidMiner Studio (5)
Cut Documentread 2026-09-27Cut a document into segments between start and end patterns (regex, XPath, JSONPath)
Split Document into Collectionread 2026-09-27Split one document into a collection of documents at a split string
Split File by Contentread 2026-09-27Split the files of a directory into segment files by regex, XPath or string matching
Split File by Pointread 2026-09-27Split the files of a directory into parts at points matching a regular expression
Window Documentread 2026-09-27Slide a window over a document's tokens and emit one document per window
Talend (1)
tChunkingread 2026-09-27Split the text of a column into smaller chunks, by fixed size or by token count
Background
In Apache Hop, the Text chunker transform splits a text field into smaller chunks and emits one output row per chunk, carrying the input row's fields.[1] In retrieval-augmented generation (RAG), chunking covers strategies for breaking up data into vectors so that the retriever can find details in it.[2]
When to use it
Retrieval-augmented generation is a technique that lets large language models retrieve and incorporate new information from external data sources.[2] In Apache Hop, chunking is the first step of a retrieval pipeline, because an embedding model has a bounded context and retrieval works better on passages than on whole documents.[1] The Apache Hop Text chunker has no dependency on an AI provider or a model, and can be used wherever a large document needs to be broken into passages.[1]
In Apache Hop, a chunk's document ID and chunk index are what let a later search merge neighbouring chunks back into a passage, and re-index a single document without touching the rest.[1] Keep each chunk with the identifier of its document and its position in it, because a chunk that has lost them cannot be put back in context. (Meridian's view) In Apache Hop's Structure strategy, each section's chunk is prefixed with a breadcrumb of its heading path, so that an isolated chunk still says where it came from.[1] Prefer the boundaries the text already has, such as paragraphs and headings, and fall back to a fixed size only where a piece runs too long. (Meridian's view)
The method
Apache Hop's Character strategy splits on a fixed character count, backing off to the nearest word boundary so that words are not cut in half.[1] In Apache Hop, chunk overlap carries the tail of each chunk into the next, which keeps a sentence that straddles a boundary retrievable from both sides.[1] Apache Hop's Paragraph strategy packs whole paragraphs up to the chunk size, and falls back to character splitting for a paragraph longer than the chunk size.[1] Apache Hop applies chunk overlap only to the Character strategy, since an overlap on paragraph or section boundaries would duplicate whole paragraphs or sections between neighbouring chunks.[1]
RapidMiner's Window Document operator moves a sliding window over the tokens of a document and returns a new document for each window.[3] In RapidMiner's Window Document operator, the window length is a number of tokens, and a step size of one makes each token the first token of a window.[3] RapidMiner's Cut Document operator segments a text by a starting and an ending regular expression, and returns a collection of the segments.[4]
Compared with the alternatives
Text segmentation is the process of dividing written text into meaningful units, such as words, sentences or topics.[5] Topic segmentation divides a document into the topics it contains, and the topic boundaries may be apparent from section titles and paragraphs.[5]
Sources
- [1]Text chunker | Apache Hopdocumentation
- [2]Retrieval-augmented generation - Wikipediasecondary source
- [3]Window Document - Rapidminer Documentationdocumentation
- [4]Cut Document - Rapidminer Documentationdocumentation
- [5]Text segmentation - Wikipediasecondary source