fix(table): row-tokenizer chunks must start at index 0 (header was left uncovered) - #639
fix(table): row-tokenizer chunks must start at index 0 (header was left uncovered)#639lntutor wants to merge 2 commits into
Conversation
…ft uncovered) The default 'row'-tokenizer path in TableChunker initialized the running offset at len(header), so the first chunk's start_index was the header length instead of 0 and the header region [0, len(header)) was never covered by any chunk's span -- original_text[start:end] returned the data rows without the header the chunk actually contains. This is inconsistent with the character-tokenizer path, which starts the first chunk at 0 and includes the header. Start the offset at 0 and add the header length to the first chunk's span so chunk spans are contiguous and tile the whole table from index 0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N6RtoHuxrDqTUo9Mw9h4Cv
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe row-tokenizer now computes contiguous table chunk spans from index ChangesTable chunk span fix
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request updates the TableChunker to ensure chunk spans are contiguous and start at index 0 by adjusting the character tracking logic. A new test case is also added to verify these indices. The review feedback points out that the current implementation of span_len does not account for the footer length in the last chunk, which is especially important for HTML tables. It suggests storing the joined chunk rows in a variable to avoid redundant joins, calculating the span length to include the footer for the last chunk, and adding a corresponding test case for HTML tables.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/chonkie/chunker/table.py`:
- Around line 152-168: Update the chunk span calculations in the table chunking
loop to account for leading whitespace in the first chunk and the footer or
trailing remainder in the final chunk, so the first span begins at the table
text start and the final end_index reaches len(text). Preserve intermediate
chunk boundaries while ensuring both Markdown and HTML tables fully cover the
original input.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 60187606-1aa0-4f90-b7a3-332e318b964a
📒 Files selected for processing (2)
src/chonkie/chunker/table.pytests/chunkers/test_table_chunker.py
What's broken
TableChunker.chunkhas two paths. The character-tokenizer path makes the first chunk start at index 0 and include the header in its span (its tests enforcechunks[0].start_index == 0). The defaultrow-tokenizer path instead initializes the running offset atlen(header):So the first chunk's
start_indexis the header length instead of 0, and the header region[0, len(header))is never covered by any chunk.original_text[start:end]then returns the data rows without the header the chunk actually contains:Fix
Start the offset at 0 and add the header length to the first chunk's span, mirroring the token path, so chunk spans are contiguous and tile the whole table from index 0.
Tests
Adds
test_table_chunker_row_tokenizer_indices(first chunk starts at 0; spans contiguous; reconstruct the full table). Fulltests/chunkers/test_table_chunker.pypasses (40). Verified via a ~2000-table fuzz that row-path spans now reconstruct from index 0 and the character path is unchanged.Summary by CodeRabbit
Bug Fixes
Tests