resume-screening-rag / src /chunking.py
btran299's picture
Update src/chunking.py
83f4cfe verified
Raw History Blame Contribute Delete
523 Bytes
from __future__ import annotations
def chunk_text(text: str, chunk_size: int = 1200, overlap: int = 200) -> list[str]:
if not text:
return []
text = text.strip()
if chunk_size <= 0:
return [text]
chunks = []
start = 0
n = len(text)
while start < n:
end = min(start + chunk_size, n)
chunk = text[start:end].strip()
if chunk:
chunks.append(chunk)
if end == n:
break
start = max(0, end - overlap)
return chunks