Cut a note into sections

Sentences

Searching one huge document all at once wastes tokens and dilutes relevance. Chunking splits a long note into focused sections (such as individual sentences or paragraphs) so retrieval pulls back only the exact lines needed to answer a question.

A long note is easier to search after it is cut into short sections. Each section should keep one idea.

Chunking cuts the note. sentence keeps each idea together. The result prints three sections.

Expected output: Chunking splits the sample note cleanly and prints the resulting three sentence sections.

Example

from praisonai import Chunking

note = (
    "Apples grow on trees in the orchard. "
    "The secret colour of the boat is blue. "
    "Tickets for the ferry cost four pounds."
)
for piece in Chunking(chunker_type="sentence", chunk_size=40).chunk(note):
    print(piece.text)
    print()

Try it Yourself

Example explained

  • Chunking — The cutter. It does not answer the question.
  • sentence — Split on sentences, so a fact is not cut in half.

Preserve headings when splitting notes

Keeping the section heading attached to each chunk ('Ferry Schedule: …') prevents orphan sentences like 'Leaves at 09:00' from losing what they refer to during retrieval.

Common pitfall: splitting blindly on fixed character counts slices numbers, dates, and URLs in half.

Reference: documentation