chore: bump fig-extract to v2.7.0 - #25
Conversation
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughfig-extract 엔진이 v2.7.0으로 갱신되며 보충 캡션 인식, 상향·하향 figure 후보 생성, 점수 기반 후보 선택이 추가되었다. 문서는 label-above 지원과 side-caption 미지원 범위를 반영했다. ChangesFigure extraction engine
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant detectPage
participant scan
participant scanDown
participant chooseCandidate
detectPage->>scan: 상향 후보 측정
detectPage->>scanDown: 하향 후보 생성
scanDown-->>detectPage: 후보와 점수 반환
detectPage->>chooseCandidate: 후보 선택 요청
chooseCandidate-->>detectPage: 선택된 figure 반환
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
Actionable comments posted: 2
🤖 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/core/fig-extract.js`:
- Around line 384-389: Update the BODY-stop check around hasImage(b0, b1) so
image detection only considers images overlapping the currently scanned column,
not merely matching the vertical range. Apply the same current-column constraint
to the raster bonus logic around the other hasImage usage (the additional
location noted in the review), preserving valid images in the active column
while excluding adjacent-column images.
- Around line 125-148: Update isCaption and the SPECIAL_CAP_RE/SPECIAL_CAP_RE2
matching path so separator-free supplementary captions such as “Supplementary
Figure 1” and “Extended Data Fig. 1” are not rejected by the length checks.
Preserve length filtering for other separator-free caption matches, while
allowing complete SPECIAL_CAP_RE* matches to return their match number.
🪄 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
Run ID: 0fec66b0-ea95-4837-b1b7-4796ae8a33af
📒 Files selected for processing (2)
docs/fig-extract-integration.mdsrc/core/fig-extract.js
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 2
🤖 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/core/fig-extract.js`:
- Around line 384-389: Update the BODY-stop check around hasImage(b0, b1) so
image detection only considers images overlapping the currently scanned column,
not merely matching the vertical range. Apply the same current-column constraint
to the raster bonus logic around the other hasImage usage (the additional
location noted in the review), preserving valid images in the active column
while excluding adjacent-column images.
- Around line 125-148: Update isCaption and the SPECIAL_CAP_RE/SPECIAL_CAP_RE2
matching path so separator-free supplementary captions such as “Supplementary
Figure 1” and “Extended Data Fig. 1” are not rejected by the length checks.
Preserve length filtering for other separator-free caption matches, while
allowing complete SPECIAL_CAP_RE* matches to return their match number.
🪄 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
Run ID: 0fec66b0-ea95-4837-b1b7-4796ae8a33af
📒 Files selected for processing (2)
docs/fig-extract-integration.mdsrc/core/fig-extract.js
🛑 Comments failed to post (2)
src/core/fig-extract.js (2)
125-148: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
구분자 없는 보충 캡션을 길이 필터에서 탈락시키지 마세요.
SPECIAL_CAP_RE*는 줄 끝을 허용하지만, Line 144와 147의 제한은Supplementary Figure 1이나Extended Data Fig. 1같은 완전 일치를 거부합니다. 캡션 본문이 다음 줄로 분리된 PDF에서 신규 캡션 형식을 놓치게 됩니다.수정 예시
if (m) { const prefix = m[1].toLowerCase().startsWith("extended") ? "ED" : "S"; - return { num: `${prefix}.${m[2]}`, sep: m[3] || "" }; + return { num: `${prefix}.${m[2]}`, sep: m[3] || "", allowBare: true }; } ... - if (![".", ":", "|"].includes(match.sep) && stripped.length > 12) return null; + if (!match.allowBare && ![".", ":", "|"].includes(match.sep) && stripped.length > 12) return null; ... - if (![".", ":", "|"].includes(match.sep) && line.s.length > 14) return null; + if (!match.allowBare && ![".", ":", "|"].includes(match.sep) && line.s.length > 14) return null;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.function matchCaption(s, compact) { let m = (compact ? SPECIAL_CAP_RE2 : SPECIAL_CAP_RE).exec(s); if (m) { const prefix = m[1].toLowerCase().startsWith("extended") ? "ED" : "S"; return { num: `${prefix}.${m[2]}`, sep: m[3] || "", allowBare: true }; } m = (compact ? LEADING_S_CAP_RE2 : LEADING_S_CAP_RE).exec(s); if (m) return { num: `S.${m[1]}`, sep: m[2] || "" }; m = (compact ? CAP_RE2 : CAP_RE).exec(s); if (m) return { num: m[2].toUpperCase(), sep: m[3] || "" }; return null; } function isCaption(line) { let match = matchCaption(line.s, false); if (!match) { const stripped = line.s.replace(/\s+/g, ""); match = matchCaption(stripped, true); if (!match) return null; if (!match.allowBare && ![".", ":", "|"].includes(match.sep) && stripped.length > 12) return null; return match.num; } if (!match.allowBare && ![".", ":", "|"].includes(match.sep) && line.s.length > 14) return null; return match.num;🧰 Tools
🪛 OpenGrep (1.25.0)
[ERROR] 126-126: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.
(coderabbit.command-injection.exec-js)
[ERROR] 131-131: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.
(coderabbit.command-injection.exec-js)
[ERROR] 133-133: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.
(coderabbit.command-injection.exec-js)
🤖 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 `@src/core/fig-extract.js` around lines 125 - 148, Update isCaption and the SPECIAL_CAP_RE/SPECIAL_CAP_RE2 matching path so separator-free supplementary captions such as “Supplementary Figure 1” and “Extended Data Fig. 1” are not rejected by the length checks. Preserve length filtering for other separator-free caption matches, while allowing complete SPECIAL_CAP_RE* matches to return their match number.
384-389: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
현재 스캔 열과 겹치는 이미지만 BODY 보호와 raster 가점에 사용하세요.
hasImage()가 세로 위치만 확인하므로, 인접 열의 이미지도 Line 386의 BODY 중단을 무효화하고 up 후보에 raster 가점을 줄 수 있습니다. 그 결과 본문을 포함한 잘못된 후보가 유효한 down 후보보다 우선될 수 있습니다.수정 예시
- const hasImage = (b0, b1) => pg.images.some(im => { + const hasImage = (b0, b1, bx0, bx1) => pg.images.some(im => { const it = im.top * S, ib = (im.top + im.h) * S; - return Math.min(ib, b1) - Math.max(it, b0) > 0.5 * (ib - it); + return Math.min(ib, b1) - Math.max(it, b0) > 0.5 * (ib - it) && + ox(im, { left: bx0, w: bx1 - bx0 }) > + 0.2 * Math.min(im.w, bx1 - bx0); }); ... - if (nstop >= guard && !hasBorder(b0, b1) && !hasImage(b0, b1)) { + if (nstop >= guard && !hasBorder(b0, b1) && + !hasImage(b0, b1, bx0, bx1)) { ... - const raster = incl.some(([a, b]) => hasImage(a, b)); + const raster = incl.some(([a, b]) => + hasImage(a, b, rx0 / S, rx1 / S));Also applies to: 890-900
🤖 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 `@src/core/fig-extract.js` around lines 384 - 389, Update the BODY-stop check around hasImage(b0, b1) so image detection only considers images overlapping the currently scanned column, not merely matching the vertical range. Apply the same current-column constraint to the raster bonus logic around the other hasImage usage (the additional location noted in the review), preserving valid images in the active column while excluding adjacent-column images.
Summary
검증된 figure 추출 엔진 v2.7.0을 byte-identical vendoring합니다. 기존에는 Figure caption이 figure 하단에 있는 경우만 탐지했으나, 이제 상단에 있는 경우도 탐지합니다. 출력 계약과 TypeScript 타입은 변경되지 않습니다.
Changes
src/core/fig-extract.js를 v2.7.0으로 갱신Test plan
npm run typechecknpm test— 26 tests passednpm run buildChecklist
chore: bump fig-extract to v2.7.0)npm run typecheck·npm test통과Summary by CodeRabbit
개선 사항
Figure N라벨이 있는 레이아웃의 인식이 개선되었습니다.문서