Repository navigation
Port remove_contents_table and short-line filter to GO - #17216
qinling0210 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThe chunker now removes TOC entries and short or numeric lines before heading analysis. New helpers support language-aware TOC matching, while PDF postprocessing adopts the same normalization and prefix behavior. Extensive tests cover TOC detection, filtering, language classification, and boundary cases. ChangesTOC and heading preprocessing
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ExtractedRecords
participant TOCFilter
participant ShortNumericFilter
participant ChunkBuilder
ExtractedRecords->>TOCFilter: remove TOC headers and entries
TOCFilter->>ShortNumericFilter: pass remaining records
ShortNumericFilter->>ChunkBuilder: pass filtered records
ChunkBuilder->>ChunkBuilder: build group or hierarchy chunks
Poem
🚥 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/ingestion/component/chunker/group.go (1)
115-119: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the
laws.py / book.pymigration-history breadcrumbs from the added comments. Both chunkers gained the same comment referencing the Python source files; the coding guideline asks that Go comments track the current runtime path rather than migration history. Keep a concise intent note and drop the cross-repo references.
internal/ingestion/component/chunker/group.go#L115-L119: trim the "Mirrors Python's remove_contents_table in laws.py / book.py" wording.internal/ingestion/component/chunker/hierarchy.go#L148-L152: apply the identical trim.🤖 Prompt for 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. In `@internal/ingestion/component/chunker/group.go` around lines 115 - 119, Trim the comments immediately above removeContentsTable in internal/ingestion/component/chunker/group.go lines 115-119 and internal/ingestion/component/chunker/hierarchy.go lines 148-152 by removing the references to Python files and migration history, while retaining a concise note explaining that TOC entries are removed before heading detection.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@internal/ingestion/component/chunker/group.go`:
- Around line 115-119: Trim the comments immediately above removeContentsTable
in internal/ingestion/component/chunker/group.go lines 115-119 and
internal/ingestion/component/chunker/hierarchy.go lines 148-152 by removing the
references to Python files and migration history, while retaining a concise note
explaining that TOC entries are removed before heading detection.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7602186c-b742-4a29-9cfa-f27c2f3eaf61
📒 Files selected for processing (6)
internal/ingestion/component/chunker/group.gointernal/ingestion/component/chunker/hierarchy.gointernal/ingestion/component/chunker/title.gointernal/ingestion/component/chunker/toc.gointernal/ingestion/component/chunker/toc_test.gointernal/parser/parser/pdf_postprocess.go
Summary
Fix the following issues:
🟡 P1 — remove_contents_table(中影响)
Python laws.py 在 tree_merge 前调用了 remove_contents_table(sections, eng)(rag/nlp/init.py:937),用于移除目录区域。
行为:检测到 "Contents"/"目录"/"TABLE OF CONTENTS" 等标记行后,删除该行及后续 128 行内匹配相同前缀的行。
为什么影响:目录条目(如"第一章"、"1.1"等)恰好匹配标题正则。不加此步骤:
触发条件:文档包含目录,且目录条目格式与正文标题格式一致。
修复位置:应放在 Parser 输出后、TitleChunker 输入前。需要决定是作为 Parser 的预处理还是 TitleChunker 的预处理。
🟢 P3 — 短行过滤(低)
Python tree_merge 内部过滤:
sections = [(t, o) for t, o in sections if t and len(t.split("@")[0].strip()) > 1 and not re.match(r"[0-9]+$", t.split("@")[0].strip())]
Go TitleChunker 没有此过滤。纯数字行如 "1" 或 "2" 可能被匹配为标题(匹配 [0-9]{1,2}[. 、] 中的 [0-9]{1,2}),引入无关标题节点。
修复成本:极低,在 resolveTitleLevels 加一行过滤即可。