4 Commits

Author SHA1 Message Date
Rudy Celekli
7842bafc0e fix(textbook_struct): keep two-char 单元 chapter token intact
The running-header normalizer's unit group used the character class
[课章节单元], which matches a single character. A 单元 (unit) token was
split: only 单 was captured and the orphaned 元 leaked into the chapter
name, so 第1单元 导论 normalized to 第1单 元 导论. The malformed title then
failed UNIT_RE_MAP[单元] matching, dropping header-embedded 单元 chapters
during rebuild. The function docstring already promises the canonical
第N单元 章名 shape. Match the two-char token first: 单元|[课章节].

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-26 10:21:21 -04:00
Bingxi Zhao (Frank)
c323516312 fix(textbook): expose header rebuild and preserve final page range 2026-09-23 10:38:16 +08:00
interia
4a01a8cffc feat(textbook): rebuild chapters from running headers embedded mid-text
Some publishers print the chapter name embedded mid-text in the running
header (e.g. "集合第1章", "空间向量与立体几何 第6章"), often without a
leading "第", while the footer only carries the publisher name — a
footer-only pass then finds zero chapters.

page_facts() now reads chapter-shaped furniture from both positions:
footer blocks matching CHAPTER_RE verbatim, and header blocks whose
chapter token sits mid-text, extracted via HEADER_CHAPTER_RE and
normalized to the canonical "第N章 章名" shape by
normalize_header_chapter() (bare token / name-before-token /
name-after-token forms; book titles, token-less headers and long prose
are rejected as boundaries). Both channels share the existing level
filter and seen-dedupe; the printed-page offset check verifies boundary
correctness end to end. Covered by 9 new tests including two-level
running-header unit filtering and offset constancy.
2026-09-11 13:30:58 +08:00
interia
0b6d5be583 feat(textbook): add textbook_struct chapter-rebuild core (footer path)
Deterministic, zero-LLM chapter tree extraction from MinerU layout.json:
column blacklist -> chapter regex -> page-top position band -> adjacent
merge, plus a header/footer path that reads the running chapter title and
the printed page number from discarded page furniture. Nothing in this
package imports deeptutor.
2026-09-11 13:28:42 +08:00