Files
C.E.L_Slide_test2/tests/matching/compare_hybrids.py
T
KyeongminandClaude Opus 4.8 b836e79ee1 wip: phase_z2 evidence 파이프라인 + matching 실험(phase2~26) + 프론트 trace 패널 진행분 스냅샷
- src: phase_z2 composition/mapper/pipeline/placement_planner/retry, ai_fallback(prompts/schema/validate), mdx_text_atoms 신규
- Front: PipelineTracePanel 신규, FramePanel/SlideCanvas/Home/designAgentApi 등 갱신 + 테스트 4종 추가
- templates/phase_z2: catalog(component_expansion_registry, node_slot_mapping 신규), frames, families, slide_base 갱신
- tests/matching: phase2~26 매칭 실험 스크립트·리포트·온톨로지 전체 (미커밋 진행분)
- tests: b4_v4 evidence, task5~28.5 시리즈, regression(imp95 baseline) 등 신규 테스트 대량 추가
- docs/reference: MDX 구조 인벤토리, MDX→Frame 구조 계약 문서
- scripts: mdx 계약/parity/coverage/viewport 체크, gitea comment, run sync 유틸
- .gitignore: tmp*.json, chromedriver, .orchestrator, *.pkl, Front_test* 등 임시/스냅샷 제외

미완성 작업의 보존용 스냅샷 커밋 (2026-07-02)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 17:03:42 +09:00

66 lines
2.1 KiB
Python

"""두 하이브리드 비교: 구조→BM25 (기존) vs BM25→구조 (역방향)"""
import sys
import json
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
from common import load_ground_truth, load_figma_texts
from extract_units import extract_units
from methods import method_hard_filter, method_bm25_then_struct
ROOT = Path(r"d:\ad-hoc\kei\design_agent")
PREVIEW_DIR = ROOT / "data" / "figma_previews"
def main():
gt_list = load_ground_truth()
figma = load_figma_texts()
units = extract_units()
with open(PREVIEW_DIR / "index.json", encoding="utf-8") as f:
idx_data = json.load(f)
frame_to_short = {info["frame_id"]: sid for sid, info in idx_data.items()}
# 7개 중목차 섹션만 (GT 있는 것)
gt_by_id = {g["id"]: g for g in gt_list}
print(f"{'섹션':15s} {'GT':5s} {'구조→BM25':15s} {'BM25→구조':15s}")
print("-" * 65)
hard_filter_hits = 0
reversed_hits = 0
total_clear = 0
for g in gt_list:
sid = g["id"]
if sid not in units:
continue
text = units[sid]
gt_short = frame_to_short.get(str(g["primary"]), "null") if g["primary"] else "null"
hf = method_hard_filter(text, figma)
rv = method_bm25_then_struct(text, figma)
hf_top = frame_to_short.get(str(hf[0][0]), "?")
rv_top = frame_to_short.get(str(rv[0][0]), "?")
hf_mark = "✅" if hf_top == gt_short else ("·" if gt_short == "null" else "✗")
rv_mark = "✅" if rv_top == gt_short else ("·" if gt_short == "null" else "✗")
print(f"{sid:15s} {gt_short:5s} {hf_mark} {hf_top:3s} ({hf[0][1]:.1f}) {rv_mark} {rv_top:3s} ({rv[0][1]:.2f})")
if g["primary"] is not None:
total_clear += 1
if hf_top == gt_short:
hard_filter_hits += 1
if rv_top == gt_short:
reversed_hits += 1
print()
print(f"기존 (구조→BM25) Hit@1: {hard_filter_hits}/{total_clear}")
print(f"역방향 (BM25→구조) Hit@1: {reversed_hits}/{total_clear}")
if __name__ == "__main__":
main()