fix: keep trailing whitespace when splitting text into sentences #13862
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 193 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.315
Real PR Conversation Timeline
1 comments
"Review active on #13862"
general
weight: 0.35
chrikrah
Related Issues
Proposed Changes:
DocumentSplitterwithsplit_by="sentence"(andsplit_by="word"withrespect_sentence_boundary=True) drops the whitespace at the end of the text. NLTK ends the last span atlen(text.rstrip()), so"One. Two.\n\n"comes back as"One. "and"Two.".SentenceSplitter.split_sentencesnow extends the last span to the end of the text whenkeep_white_spacesis on. Withkeep_white_spaces=Falsenothing changes. Use case: files read from disk usually end with a newline, which was lost in the last chunk.How did you test it?
New unit tests in
test_sentence_tokenizer.py(trailing newline,\n\n, form feed, spaces, and thekeep_white_spaces=Falsecontrol) andtest_document_splitter.py(chunks add up to the original text for both split modes). The new tests fail without the change and pass with it.test/components/preprocessorsandtest/components/retrieverspass,ruff checkandruff format --checkare clean.Notes for the reviewer
None.
Checklist
fix:.This PR was fully generated with an AI assistant. I have reviewed the changes and run the relevant tests.