Первый коммит

This commit is contained in:
2026-02-25 14:47:19 +03:00
commit 43c404f958
171 changed files with 4917 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
class TextChunker:
def __init__(self, chunk_size: int = 900, overlap: int = 120) -> None:
self._chunk_size = chunk_size
self._overlap = overlap
def chunk(self, text: str) -> list[str]:
cleaned = text.replace("\r\n", "\n")
if not cleaned.strip():
return []
chunks: list[str] = []
start = 0
while start < len(cleaned):
end = min(len(cleaned), start + self._chunk_size)
piece = cleaned[start:end].strip()
if piece:
chunks.append(piece)
if end == len(cleaned):
break
start = max(0, end - self._overlap)
return chunks