WIP on main: 1f7579c Phase W + V' 완료: before→filled→after 파이프라인 + 조립 로직 수정

This commit is contained in:
2026-04-06 07:23:35 +09:00
13 changed files with 1036 additions and 383 deletions
+20 -14
View File
@@ -304,8 +304,16 @@ def calculate_fit(
if normalized is None:
normalized = {}
role_font_map = {"본심": "core", "배경": "bg", "첨부": "sidebar", "결론": "key_msg"}
role_line_height = {"본심": 1.5, "배경": 1.4, "첨부": 1.4, "결론": 1.3}
# Phase X: zone 기반 font/line_height 결정 (고정 역할명 불필요)
def _font_key_for_role(role_name):
zone = containers.get(role_name, {}).get("zone", "")
if zone == "footer": return "key_msg"
if zone == "sidebar": return "sidebar"
return "core"
def _line_height_for_role(role_name):
zone = containers.get(role_name, {}).get("zone", "")
if zone == "footer": return 1.3
return 1.5
analysis = FitAnalysis()
@@ -327,9 +335,9 @@ def calculate_fit(
allocated_h = container.get("height_px", 0)
width_px = container.get("width_px", 0)
font_key = role_font_map.get(role, "core")
font_key = _font_key_for_role(role)
font_size = font_hierarchy.get(font_key, 12)
line_h = role_line_height.get(role, 1.5)
line_h = _line_height_for_role(role)
# V-1 출력: 꼭지별 블록 리스트
ref_list = references.get(role, [])
@@ -375,7 +383,8 @@ def calculate_fit(
has_image = img_h > 0
# ── 4. key-msg (본심에만) ──
has_keymsg = (role == "본심" and core_message)
# keymsg: 이미지가 있는 역할에만 (zone 무관, 블록 기반)
has_keymsg = (has_image and core_message)
keymsg_h = estimate_keymsg_height(core_message, font_hierarchy.get("key_msg", 14)) if has_keymsg else 0
# ── 5. 블록 오버헤드 ──
@@ -485,12 +494,7 @@ def build_escalation_report(analysis: FitAnalysis) -> str:
return "\n".join(lines)
ROLE_ZONE_MAP = {
"본심": "body",
"배경": "body",
"첨부": "sidebar",
"결론": "footer",
}
# Phase X: ROLE_ZONE_MAP 제거. containers에서 zone을 직접 읽음.
def redistribute(
@@ -504,7 +508,9 @@ def redistribute(
"""
zone_roles: dict[str, list[str]] = {}
for role in analysis.roles:
zone = ROLE_ZONE_MAP.get(role, "body")
# Phase X: containers에서 zone 직접 읽기 (고정 맵 불필요)
ci = containers.get(role, {})
zone = ci.get("zone", "body") if isinstance(ci, dict) else "body"
if zone not in zone_roles:
zone_roles[zone] = []
zone_roles[zone].append(role)
@@ -939,8 +945,8 @@ def calculate_sub_layout(
layout = ContainerLayout(role=role, main_height_px=main_height_px, main_width_px=main_width_px)
# 제목 높이: font_size * line_height + margin
role_font_map = {"본심": "core", "배경": "bg", "첨부": "sidebar", "결론": "key_msg"}
font_key = role_font_map.get(role, "core")
# Phase X: font_key는 font_hierarchy에서 가장 가까운 키 사용
font_key = "core" # 기본값. zone 정보가 없으면 core
title_font = font_hierarchy.get(font_key, 12)
title_h = title_font * 1.5 + tokens["spacing_small"]