fix(rag): preserve structurally empty Word paragraph boundaries - #2969
Open
liugy789 wants to merge 2 commits into
Open
fix(rag): preserve structurally empty Word paragraph boundaries#2969liugy789 wants to merge 2 commits into
liugy789 wants to merge 2 commits into
Conversation
…ader In .docx files a blank line is stored as an empty <w:p> element. WordReader.getDataBlocks() skipped empty paragraphs entirely, so consecutive paragraphs were joined with a single "\n". As a result TextChunker's PARAGRAPH_SEPARATOR regex (\n\s*\n) never matched and the PARAGRAPH split strategy degenerated into character-based hard splitting at chunkSize, cutting paragraphs mid-sentence. Append a "\n" for blank paragraphs under the same merge conditions as non-empty text, so that adjacent paragraphs are joined with "\n\n" and the paragraph boundary is preserved for chunking.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Author
Thanks! I’ve signed the ICLA now, and the CLA check is green. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.0.3-SNAPSHOT (current main)
Description
Word represents a blank line as an empty
w:pparagraph.WordReadernow preserves that structural boundary so paragraph chunking receives\n\nbetween surrounding text.The blank-paragraph check is deliberately structural: a paragraph containing only
w:pPrproperties remains blank, while a paragraph with any other OOXML body element (for example a run containingw:br) is not treated as an extra blank-line boundary. This prevents trim-normalized but structurally non-empty paragraphs from changing chunk boundaries.Testing
WordReaderTest: 15 tests, 0 failures, 0 errors.w:pPr-only paragraphs, and break-only paragraphs.spotless:checkandgit diff --checkpass.Checklist
mvn spotless:check