File size: 276 Bytes
4a8b2d1
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
def chunk_text(text, chunk_size=200):  # smaller chunk
    words = text.split()
    
    if len(words) == 0:
        return []

    chunks = []
    for i in range(0, len(words), chunk_size):
        chunks.append(" ".join(words[i:i + chunk_size]))

    return chunks