Chunk documents at sentence boundaries with a token budget and a little overlap, so a fact split across a boundary still appears whole in one chunk.
Implement chunk_sentences(text, max_tokens, overlap_sentences=1, count_tokens=lambda s: len(s.split())):
., ! or ? followed by whitespace. Strip each sentence and drop empty ones.<= max_tokens.overlap_sentences sentences of the previous chunk (if they fit with the next sentence; drop overlap sentences from the front until they do).max_tokens becomes its own chunk, unsplit.