Skip to content

Fixes an chunking issues with decorative separator lines. +Testing#156

Open
Torlek wants to merge 3 commits into
devnen:mainfrom
Torlek:fix_decorative_lines
Open

Fixes an chunking issues with decorative separator lines. +Testing#156
Torlek wants to merge 3 commits into
devnen:mainfrom
Torlek:fix_decorative_lines

Conversation

@Torlek

@Torlek Torlek commented Jul 2, 2026

Copy link
Copy Markdown

In the attached text everything between the * * * * * separators is one chunk. This patch fixes this. I also added expandable testing to prevent future regression.
5star.txt
I also added an option to set a hard limit on chunk size. This behavior defaults to off.

Copilot AI review requested due to automatic review settings July 2, 2026 05:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the text chunking pipeline in utils.py so Markdown-style decorative separator lines (e.g., * * * * *, ---) act as hard paragraph breaks instead of causing large “glued” chunks, and adds an optional config-driven hard-length fallback split to prevent oversized single segments. It also introduces regression tests and configuration defaults for the new behavior.

Changes:

  • Treat symbol-only divider lines as hard paragraph separators during sentence splitting to prevent separator blocks from merging unrelated prose.
  • Add an optional hard limit fallback (disabled by default) that splits oversized single segments at a configurable multiple of chunk_size.
  • Add regression tests covering divider-line behavior, prior regressions, and the hard-limit fallback option.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
utils.py Adds divider-line paragraph splitting and an optional hard-limit fallback splitter for oversized segments.
tests/test_chunking_regressions.py Adds regression coverage for divider-line chunking and the new hard-limit fallback behavior.
config.yaml Introduces text_chunking configuration defaults for the hard-limit fallback feature.
config.py Adds default config schema entries for text_chunking options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_chunking_regressions.py Outdated
Comment on lines +15 to +17
from msgpack import fallback
from sympy import false
from utils import chunk_text_by_sentences, config_manager
Comment thread tests/test_chunking_regressions.py Outdated
hard_limit_factor=4.0,
),
ChunkCountCase(
id="Original example text with five star issue",
Comment thread tests/test_chunking_regressions.py Outdated
expected_chunks=8,
),
ChunkCountCase(
id="Original text with dash issue",
Comment thread utils.py
Comment on lines +1048 to +1052
while len(remaining) > max_len:
split_at = remaining.rfind(" ", 0, max_len + 1)
if split_at <= 0:
split_at = max_len

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants