Spaces:
Sleeping
Sleeping
| def fixed_length_chunking(text, chunk_size=500, overlap=50): | |
| """Split text into fixed-length chunks.""" | |
| chunks = [] | |
| start = 0 | |
| while start < len(text): | |
| end = start + chunk_size | |
| chunk = text[start:end].strip() | |
| if chunk: | |
| chunks.append(chunk) | |
| start = end - overlap if end < len(text) else end | |
| return chunks | |