Back to Graphrag

Copyright (c) 2026 Microsoft Corporation.

packages/graphrag-chunking/example_notebooks/basic_sentence_example.ipynb

3.0.9591 B
Original Source
python
# Copyright (c) 2026 Microsoft Corporation.
# Licensed under the MIT License.

Basic sentence chunking with nltk

The SentenceChunker class splits text into individual sentences by identifying sentence boundaries. It takes input text and returns a list where each element is a separate sentence, making it easy to process text at the sentence level.

python
from graphrag_chunking.sentence_chunker import SentenceChunker

chunker = SentenceChunker()
chunks = chunker.chunk("This is a test. Another sentence.")
print(chunks)  # ["This is a test.", "Another sentence."]