File size: 245 Bytes
4c0ae33
 
 
 
 
 
 
1
2
3
4
5
6
7
8
def chunk_text(text, chunk_size=300, overlap=50):
    words = text.split()
    chunks = []
    for i in range(0, len(words), chunk_size - overlap):
        chunk = " ".join(words[i:i + chunk_size])
        chunks.append(chunk)
    return chunks