Spaces:
Paused
Paused
Download core/search.py from TeamError404/nexus: direct link, hf CLI and curl.
- Browser
- Download file 732 Bytes
-
https://huggingface.co/spaces/TeamError404/nexus/resolve/main/core/search.py
- Command line
-
hf download hf://spaces/TeamError404/nexus/core/search.py
-
curl -L -o search.py https://huggingface.co/spaces/TeamError404/nexus/resolve/main/core/search.py
732 Bytes
| from typing import List | |
| def chunk_text(text: str, chunk_size: int = 600, chunk_overlap: int = 100) -> List[str]: | |
| """ | |
| Simple recursive-style character splitter for text chunking. | |
| Ensures chunks have the specified overlap for context preservation. | |
| """ | |
| if not text: | |
| return [] | |
| chunks = [] | |
| start = 0 | |
| while start < len(text): | |
| end = start + chunk_size | |
| chunk = text[start:end] | |
| chunks.append(chunk) | |
| # Move start forward by chunk_size minus overlap | |
| start += (chunk_size - chunk_overlap) | |
| # Prevent infinite loop if overlap >= size | |
| if chunk_overlap >= chunk_size: | |
| start = end | |
| return chunks | |