MCPcopy
hub / github.com/unclecode/crawl4ai / FixedLengthWordChunking

Class FixedLengthWordChunking

crawl4ai/chunking_strategy.py:85–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83
84# Fixed-length word chunks
85class FixedLengthWordChunking(ChunkingStrategy):
86 def __init__(self, chunk_size=100, **kwargs):
87 """
88 Initialize the fixed-length word chunking strategy with the given chunk size.
89
90 Args:
91 chunk_size (int): The size of each chunk in words.
92 """
93 self.chunk_size = chunk_size
94
95 def chunk(self, text: str) -> list:
96 words = text.split()
97 return [' '.join(words[i:i + self.chunk_size]) for i in range(0, len(words), self.chunk_size)]
98
99# Sliding window chunking
100class SlidingWindowChunking(ChunkingStrategy):

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…