Skip to content

Official Crawl4AI Cloud: a hosted web scraping, extraction, and search API for AI agents. Free API key, 1,000 credits a month, no card. Fully open source: this repo is the Apache-2.0 crawler that powers it, and you can self-host it.

fix(chunking): preserve sentence order in NlpSentenceChunking (#1909)

ntohidic837c0d9cb16
diff --git a/crawl4ai/chunking_strategy.py b/crawl4ai/chunking_strategy.py
index f46cb667..a0bfe1bf 100644
--- a/crawl4ai/chunking_strategy.py
+++ b/crawl4ai/chunking_strategy.py
@@ -71,7 +71,6 @@ class NlpSentenceChunking(ChunkingStrategy):
"""
Initialize the NlpSentenceChunking object.
"""
- from crawl4ai.le.legacy.model_loader import load_nltk_punkt
load_nltk_punkt()
def chunk(self, text: str) -> list:
@@ -86,7 +85,7 @@ class NlpSentenceChunking(ChunkingStrategy):
sentences = sent_tokenize(text)
sens = [sent.strip() for sent in sentences]
- return list(set(sens))
+ return sens
# Topic-based segmentation using TextTiling