File size: 255 Bytes
f641099 |
1 2 3 4 5 6 7 |
from typing import List
def chunk_text(text: str, chunk_size: int = 10) -> List[str]:
words = text.split()
if len(words) <= chunk_size:
return [text]
return [' '.join(words[i:i + chunk_size]) for i in range(0, len(words), chunk_size)] |