Repository navigation
fix(parser): slice PDF TOC prefix by characters, not bytes - #19745
coderdailyone wants to merge 1 commit into
Conversation
removePDFTOC ports Python's remove_contents_table (rag/nlp/__init__.py): after dropping the TOC heading and first entry it deletes all sections up to the next one sharing that entry's 3-character prefix. sectionTextPrefix computed the prefix as text[:3] (bytes), so a Chinese entry like "第一章 绪论" yielded only "第" — the terminator scan then matched the very next 第-prefixed chapter entry, deleted nothing, and the whole remaining TOC list survived into chunks. Slice runes instead, matching Python's get(i)[:3]. Regression test: TestApplyPDFPostProcess_RemoveTOCPrefixScanCJKEntries fails with the source change reverted. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01CRrBenkCCr4pacMNwR4NuG
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe PDF TOC prefix helper now slices Unicode characters instead of bytes. A regression test covers CJK chapter entries during TOC removal. ChangesPDF TOC prefix handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The PDF TOC removal update preserves complete Unicode characters and includes coverage for CJK entries; no merge-blocking issue remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. A rabbit found three runes in line Comment |
|
LGTM |
|
#19779 is better than this. |
Summary
removePDFTOCports Python'sremove_contents_table(rag/nlp/init.py): after dropping the "目录"/"contents" heading and the first entry, it deletes all sections up to the next one sharing that entry's 3-character prefix — the matching body heading.sectionTextPrefixcomputed the prefix astext[:3](bytes) instead of the first 3 characters. For the standard Chinese TOC entry "第一章 绪论" the byte slice yields only "第", so the terminator scan matched the very next "第..." chapter entry, deleted nothing, and the whole remaining TOC entry list survived into chunks. A leading multi-byte rune whose width is not a multiple of 3 could also produce an invalid UTF-8 prefix matching nothing.Fix: convert to
[]runeand slice the firstnrunes, matching Python'sget(i)[:3]and the siblingtocPrefixintext_toc.go.Regression test:
TestApplyPDFPostProcess_RemoveTOCPrefixScanCJKEntriesininternal/parser/parser/pdf_postprocess_test.go— fails with the source change reverted (kept第二章 背景,第三章 方法), passes with the fix.Type of change
Fixes #19744
🤖 Generated with Claude Code
https://claude.ai/code/session_01CRrBenkCCr4pacMNwR4NuG