fix(ir): 캡션/각주/미주 평문화에서 ListItemBlock 누락 정정#7
Merged
Conversation
LangChain HwpLoader (mode=ir-blocks) 와 CLI rhwp-py blocks --format text 가 각주·미주·캡션 본문을 평문화할 때 ParagraphBlock 만 처리하여, 본문 안의 ListItemBlock 이 통째로 RAG 색인에서 누락됐다. 변환 경로상 ParaShape.head_type 가 비-None 이면 _flatten_paragraph 가 ParagraphBlock 대신 ListItemBlock 을 emit 하므로, 각주 본문에 list 가 있는 HWP 문서는 LangChain Document 의 page_content 가 비거나 list 항목이 빠진다. CLI text 포맷도 같은 누락. 수정: - python/rhwp/ir/_plain_text.py 신규 — block_inline_text / join_inline_blocks 헬퍼. ParagraphBlock + ListItemBlock + FormulaBlock + FieldBlock 을 인라인- 스러운 블록으로 분류해 평문 추출. LangChain integration 과 CLI 가 공유 하는 SSOT. - langchain.py 의 _caption_plain_text 제거, footnote/endnote/caption/picture 분기에서 join_inline_blocks 사용. - cli/ir.py 의 _caption_plain 제거, _block_to_text 의 footnote/endnote/caption 분기에서 같은 헬퍼 사용. PictureBlock caption 분기도 동일. 테스트: - tests/test_ir_plain_text.py 신규 — 헬퍼 단위 테스트 (인라인/구조/빈 블록 분류 + ListItemBlock 결합). - tests/test_langchain_loader_ir.py 에 footnote/caption 회귀 테스트 2종 추가 (private helper 직접 호출 — sample 파일의 footnote 구조에 의존하지 않음). - tests/test_cli.py 에 _block_to_text footnote 회귀 테스트 1종 추가. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
`HwpLoader(mode="ir-blocks")` 와 CLI `rhwp-py blocks --format text` 가 각주·미주·캡션 본문을 평문화할 때 `ParagraphBlock` 만 처리하여, 본문 안의 `ListItemBlock` 이 통째로 RAG 색인에서 누락됐다.
Why
ParaShape.head_type 가 비-None 이면 `_flatten_paragraph` 가 `ParagraphBlock` 대신 `ListItemBlock` 을 emit 한다. 각주 본문에 list 가 있는 HWP 문서는:
`spec § 5` 의 "캡션 안의 인라인 수식·필드도 자연스럽게 표현" 정책이 `_caption_plain_text` 에는 적용됐지만 footnote/endnote 평문화에는 누락된 채로 ParagraphBlock-only 였음 — 두 헬퍼 정책 일관성 깨짐도 동시 정정.
Related Issues
없음 — 코드 리뷰 중 발견.
Test plan