Repository navigation
refactor(parser): align TextParser with Python _code delimiter split - #18099
Closed
xugangqiang wants to merge 2 commits into
Closed
xugangqiang wants to merge 2 commits into
xugangqiang wants to merge 2 commits into
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
xugangqiang
force-pushed
the
fix/textcode-parser-align
branch
from
August 11, 2026 08:46
2d8775d to
0e8c69d
Compare
xugangqiang
force-pushed
the
fix/parser-align-foundation
branch
from
August 11, 2026 09:17
f2e724d to
1e39d24
Compare
Make Go TextParser match Python deepdoc TxtParser._code: - Split on the flow default delimiter set "\n!?;。;!?" (was blank-line only). - keep_delimiters=True: each trailing delimiter is retained on its segment. - Normalize CRLF/CR -> LF like Python. - Do NOT perform the OVER_CAP token merge; chunking stays with the downstream Chunker (PARSER_ALIGNMENT_HANDOFF.md §2.3). - The 8192-byte per-item cap is dropped: the parser is a pure delimiter splitter, matching Python's parser_txt (no size slicing). Sizing is delegated to the Chunker + embedding truncation per contract #17799. Tests: - TestTextParser_ParseWithResult_DefaultDelimiter pins the new split rule (single-newline + sentence-delimiter splitting with delimiter retained). - TestTextParser_ParseWithResult_NoSizeCap pins no per-item byte slicing. - TestTextParser_AlignmentGolden verifies content-equivalence vs the Python golden on a shared sample. Depends on #18014 and the foundation helpers PR (align_test.go). Files: internal/parser/parser/text_parser.go internal/parser/parser/parse_with_result_test.go internal/parser/parser/testdata/textcode.sample.txt (new) internal/parser/parser/testdata/textcode.python.golden.json (new)
…-delimiter test - text_parser.go now uses the shared DefaultTextCodeDelimiter from delimiter.go instead of a private duplicate that could drift silently. - Fix the golden-regeneration comment: no generator script is committed; the baseline is reproducible from the golden's meta block. - Add TestTextParser_AdjacentDelimiters pinning the documented adjacent- delimiter behavior (Go drops the standalone second delimiter) so a future silent change in splitCapturingDelims is caught.
xugangqiang
force-pushed
the
fix/textcode-parser-align
branch
from
August 11, 2026 09:21
0e8c69d to
f8688b1
Compare
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.
Summary
Make Go
TextParsermatch Pythondeepdoc TxtParser._code:\n!?;。;!?(was blank-line only).keep_delimiters=True: each trailing delimiter is retained on its segment.Chunker (PARSER_ALIGNMENT_HANDOFF.md §2.3).
splitter, matching Python's
parser_txt(no size slicing). Sizing isdelegated to the Chunker + embedding truncation — see contract Internal discussion: TokenChunker contract — delimiter boundary + token_size soft-target merge #17799 below.
Why dropping the 8192-byte cap is safe (contract #17799)
The parser layer must NOT do token-size splitting.
internal/ingestion/component/chunker/token.go(OVER-BUDGET UNITS, contract #17799) states: a single item exceeding
chunk_token_sizeis KEPT WHOLE as its own chunk and is NOT atom-split; thedownstream embedding/rerank layer truncates it later. Token-size chunking —
including any oversized-item handling — belongs to the Chunker (or a PreSplitter
stage between Parser and Chunker), explicitly NOT in the parser and NOT as a
char-window split. So removing the per-item byte cap converges Go with Python's
parser_txt(which also does no size slicing) instead of diverging, and theChunker already owns the oversized-item case.
Test plan
TestTextParser_ParseWithResult_DefaultDelimiterpins the new split rule(single-newline + sentence-delimiter splitting with delimiter retained).
TestTextParser_ParseWithResult_NoSizeCappins no per-item byte slicing.TestTextParser_AdjacentDelimiterspins the documented adjacent-delimiterbehavior (Go drops the standalone second delimiter) so a future silent change
in
splitCapturingDelimsis caught.TestTextParser_AlignmentGoldenverifies content-equivalence vs the Pythongolden on a shared sample.
Dependency
Stacks on #18014 (framework in
main) and the foundation helpers PR(
fix/parser-align-foundation).Note
Adjacent-delimiter input (e.g.
"a..b") keeps only the merged segment in Gowhile Python keeps the second delimiter as its own segment. The alignment test
normalizes this away; tracked as a known follow-up, not fixed here.