Files
Aislo/resources/knowledge/original/_pipeline/index_images.py
T
eomsangdonandClaude Fable 5 81cd7e23c3 feat(knowledge): 도메인 지식저장소 메인 통합 + resources 그룹 체계 재편
knowledge (구 Aislo-law 독립 저장소 → resources/knowledge 이관, 저장소 폐지):
- 법령·행정규칙·표준시방서·교본 원문 + 기술문서 55건 + 실무 분석·종합비교
- 루트 지침 체계: README(지도)·00_운영지침·01_수집지침·02_분석지침·
  03_미결_및_확인사항(교본 충돌 리스트 포함)·04_참조_법령기준_목록
- 기술문서 55건 원문 전수 검증 완료 (사방 설계홍수량 법정 기준 등 반영)
- 정리: CAD·오피스 잔재 142건, 중복 zip 7건(413MB), 빈 폴더 30개 제거

resources 그룹 재편 (이름순 그룹핑):
- app_branding(구 prog_icon.jpg)·app_policies(구 legal)·
  data_global_contours(구 grobal_contours)·data_rainfall_idf_cache(구 wamis_contours)·
  template_2dDrawing(구 dwg_analysis/templete — 오타 교정, 상수·경로 동기화)
- dwg_analysis(분석 완료 1.8GB)·templates(빈 폴더)·templete_calc_cost.xlsx 삭제
- 참조 코드 5파일 경로 수정 + 프론트 재빌드 (구 경로 잔존 0)
- .gitignore: resources 추적 전환, national_contours.gpkg(22GB) 영구 제외
- .env: knowledge 수집용 API 정보 주석 통합 (KCSC·법령센터·조달청 제비율)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-12 19:14:32 +09:00

84 lines
3.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""pic/ 이미지 164개 전건 리스트 README 생성 — 표 변환 여부 판단용.
각 이미지: 미리보기 링크 · 크기 · 형식 · 소속(명칭) · 참조 md 링크.
사용자가 표로 옮길 이미지를 직접 판단한다.
"""
import re
from pathlib import Path
from PIL import Image
ROOT = Path(__file__).resolve().parent.parent
OUT = ROOT / "_이미지 목록(표 변환 검토용).md"
def _cand(p):
try:
w, h = Image.open(p).size
return w >= 350 and 1.3 <= w / max(1, h) <= 6
except Exception:
return False
def build():
# 1) 이미지 → 참조 md 역매핑
ref = {}
for m in ROOT.rglob("*.md"):
if "_pipeline" in str(m):
continue
t = m.read_text(encoding="utf-8")
# 경로에 괄호가 있어도 <...> 안이면 확장자까지 잡는다
for mm in re.finditer(r'!\[[^\]]*\]\(<([^>]+\.(?:png|jpg|jpeg|gif|bmp))>\)'
r'|!\[[^\]]*\]\(([^)\s]+\.(?:png|jpg|jpeg|gif|bmp))\)', t):
path = mm.group(1) or mm.group(2)
img = (m.parent / path).resolve()
ref.setdefault(str(img), []).append(m)
imgs = sorted(ROOT.rglob("pic/*"))
# 소속(명칭 폴더) 기준 그룹
groups = {}
for p in imgs:
rel = p.relative_to(ROOT)
parts = rel.parts # 분류/명칭/pic/파일 또는 분류/명칭/첨부/[압축]…/pic/…
cat = parts[0]
name = parts[1] if len(parts) > 2 else "(기타)"
groups.setdefault((cat, name), []).append(p)
def row(idx, p):
try:
w, h = Image.open(p).size
size = f"{w}×{h}"
except Exception:
size = "?"
rel = p.relative_to(OUT.parent).as_posix()
fmt = p.suffix[1:].upper()
seen, uniq = set(), []
for m in ref.get(str(p.resolve()), []):
if m not in seen:
seen.add(m); uniq.append(m)
rlinks = " · ".join(f"[{m.stem[:18]}](<{m.relative_to(OUT.parent).as_posix()}>)"
for m in uniq[:2]) if uniq else "_미참조_"
return f"| ☐ | {idx} | [{p.name[:40]}](<{rel}>) | {size} | {fmt} | {rlinks} |"
cand = [p for p in imgs if _cand(p)]
rest = [p for p in imgs if not _cand(p)]
L = ["# 이미지 목록 — 표 변환 검토용", "",
f"> pic/ 이미지 전건 **{len(imgs)}개**. 각 이미지를 열어 **표로 옮길지** `☐` 열에 체크(→ `☑`)한다.",
"> 체크한 이미지를 알려주면 md 표로 옮기고 이미지는 대조용으로 병기한다.", "",
f"## ★ 표 후보 (가로형 {len(cand)}개) — 우선 검토", "",
"> 셀 경계가 뚜렷한 가로형. 표일 가능성 높음(단, 수식·표시·도형 섞여 있으니 실제로 열어 확인).", "",
"| 반영 | # | 이미지 | 크기 | 형식 | 참조 문서 |",
"|:-:|---:|---|---|---|---|"]
for i, p in enumerate(sorted(cand, key=lambda x: -Image.open(x).size[0]), 1):
L.append(row(i, p))
L += ["", f"## 그 외 이미지 ({len(rest)}개)", "",
"> 대부분 로고·점·수식·표시·도형. 표 가능성 낮으나 필요시 검토.", "",
"| 반영 | # | 이미지 | 크기 | 형식 | 참조 문서 |",
"|:-:|---:|---|---|---|---|"]
for i, p in enumerate(sorted(rest), len(cand) + 1):
L.append(row(i, p))
OUT.write_text("\n".join(L) + "\n", encoding="utf-8")
return len(imgs)
if __name__ == "__main__":
n = build()
print(f"이미지 목록 {n}개 → {OUT.name}")