Spaces:
Runtime error
Runtime error
Download text.py from aayush226/GraphRAG-Live: direct link, hf CLI and curl.
- Browser
- Download file 471 Bytes
-
https://huggingface.co/spaces/aayush226/GraphRAG-Live/resolve/main/text.py
- Command line
-
hf download hf://spaces/aayush226/GraphRAG-Live/text.py
-
curl -L -o text.py https://huggingface.co/spaces/aayush226/GraphRAG-Live/resolve/main/text.py
471 Bytes
| def chunk_text(text: str, chunk_size : int = 200, overlap: int = 50) -> str: | |
| """ | |
| Here, we will break the text into overlapping chunks and then feed | |
| them to the embedding pipeline | |
| """ | |
| chunks = [] | |
| start = 0 | |
| while start < len(text): | |
| end = start + chunk_size | |
| curr_chunk = text[start:end] | |
| chunks.append(curr_chunk) | |
| start += chunk_size - overlap # we need some overlap between the chunks | |
| return chunks |