chore: WebforAI 아웃바운드 1군 5곳 실측·진단 보고서·소개서 파이프라인
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f1f311498a
commit
779406743b
46 files changed
+11662
No files matched your search
@@ -0,0 +1,99 @@
|
||||
"""
|
||||
haewon이 확정한 소개서(그랜드 v13)를 틀로 삼아 다른 병원 소개서를 만든다.
|
||||
|
||||
- 틀의 레이아웃·글꼴·문구는 그대로 두고 병원별로 달라지는 곳만 바꾼다
|
||||
1 표지 병원명 · 2 출처 분석 건수·자주 인용된 플랫폼 · 4 핵심 발견 · 5 보고서 제목 · 6 요약 제목 · 9·10 답변 장 제목
|
||||
- 보고서 장(5~12) 본문은 report_native 로 이 병원 실측값을 다시 그린다
|
||||
- 저장 전에 틀 병원의 이름·시술·질문이 남아 있지 않은지 검사한다
|
||||
|
||||
python3 docs/reports/outbound_webforai/build_clinic_deck.py <틀.pptx> <출력.pptx> <병원명>
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
from pptx import Presentation
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
import build_diagnosis_report as report # noqa: E402
|
||||
import build_outbound_deck_v3 as v3 # noqa: E402
|
||||
import report_native # noqa: E402
|
||||
import run_outbound_probe as probe # noqa: E402
|
||||
|
||||
TEMPLATE_CLINIC = "그랜드성형외과"
|
||||
CONTACT = report.CONTACT
|
||||
|
||||
|
||||
def shape(slide, name):
|
||||
return next(sh for sh in slide.shapes if sh.name == name)
|
||||
|
||||
|
||||
def set_runs(shape_, texts):
|
||||
"""문단마다 첫 run 서식을 살려 텍스트만 바꾼다. texts 는 문단별 문자열."""
|
||||
paras = shape_.text_frame.paragraphs
|
||||
assert len(paras) == len(texts), f"{shape_.name}: 문단 수 {len(paras)} ≠ {len(texts)}"
|
||||
for p, t in zip(paras, texts):
|
||||
runs = p.runs
|
||||
runs[0].text = t
|
||||
for r in runs[1:]:
|
||||
r._r.getparent().remove(r._r)
|
||||
|
||||
|
||||
def deck_text(prs):
|
||||
return "\n".join(sh.text_frame.text for s in prs.slides for sh in s.shapes if sh.has_text_frame)
|
||||
|
||||
|
||||
def main(template, out, name):
|
||||
assert not os.path.exists(out), f"이미 있는 파일은 덮어쓰지 않습니다: {out}"
|
||||
clinics = probe.load("pilot_clinics.json")
|
||||
clinic = next(c for c in clinics if c["name"] == name)
|
||||
tmpl = next(c for c in clinics if c["name"] == TEMPLATE_CLINIC)
|
||||
_, plan = probe.expand(clinics, probe.load("question_template.json"))
|
||||
d = report.report_data(clinic, plan)
|
||||
kf = d["kf"]
|
||||
prs = Presentation(template)
|
||||
s = prs.slides
|
||||
|
||||
# 1 표지
|
||||
set_runs(shape(s[0], "TextBox 6"), [name])
|
||||
# 2 Why Now: OPEN WEB 카드 하단 라벨
|
||||
set_runs(shape(s[1], "TextBox 47"), [f"답변 {d['total']}건 출처 분석"])
|
||||
# OPEN WEB 카드 첫 줄: 이 병원 답변에서 많이 인용된 플랫폼 2곳 (강남구청은 다음 줄 '구청·의료관광·후기'에 있음)
|
||||
top = [lb for lb, _ in d["src"] if lb != "강남구청"][:2]
|
||||
line = next(sh for sh in s[1].shapes if sh.has_text_frame
|
||||
and (sh.text_frame.text == "플랫폼 인용이 더 많음" or sh.text_frame.text.endswith("자주 인용")))
|
||||
set_runs(line, [f"{top[0]}·{top[1]} 자주 인용"])
|
||||
# 3 측정 방법: 질의 횟수
|
||||
runs = sum(len(report.judged_runs(clinic, qid, e)) for qid in plan[name].values() for e, _ in report.ENGINES)
|
||||
set_runs(shape(s[2], "TextBox 35"), [str(runs)])
|
||||
# 4 핵심 발견 (히어로 80pt 한 줄씩)
|
||||
for ln in kf["hero"]:
|
||||
v3._check(ln, v3.W, 80.0, 1, f"hero «{ln}»")
|
||||
set_runs(shape(s[3], "TextBox 2"), kf["hero"])
|
||||
set_runs(shape(s[3], "TextBox 4"), [kf["hero_sub"]])
|
||||
# 5·6 보고서 표지·요약 제목
|
||||
set_runs(shape(s[4], "TextBox 2"), [f"{name} 맞춤 진단 보고서"])
|
||||
set_runs(shape(s[5], "TextBox 2"), [kf["title"]])
|
||||
# 9·10 답변 장 제목
|
||||
for i, q in zip((8, 9), d["quotes"]):
|
||||
where = "국내" if q["loc"].startswith("서울") else "해외"
|
||||
set_runs(shape(s[i], "TextBox 2"), [f"{where} 환자 질문에 대한 {q['engine']}의 실제 답변"])
|
||||
report_native.build(prs, d)
|
||||
# 15 클로징 문의 버튼: haewon 이 v13 에서 문구를 sales@ 로 바꿨으므로 링크도 맞춘다
|
||||
for sh in s[14].shapes:
|
||||
if sh.click_action.hyperlink.address:
|
||||
sh.click_action.hyperlink.address = f"mailto:{CONTACT}"
|
||||
assert CONTACT in deck_text(prs), "클로징 문의처 문구와 링크가 다릅니다"
|
||||
|
||||
# 틀 병원의 흔적 검사: 병원명·영문명·도메인·시술명·질문 원문
|
||||
text = deck_text(prs)
|
||||
left = [w for w in [tmpl["name"], tmpl["name_en"], *tmpl["aliases"], *tmpl["domains"], "그랜드", "Grand"]
|
||||
if w and w in text]
|
||||
if tmpl["procedure_ko"] != clinic["procedure_ko"]:
|
||||
left += [w for w in (tmpl["procedure_ko"], tmpl["procedure_en"]) if w in text]
|
||||
assert not left, f"틀 병원 흔적이 남았습니다: {left}"
|
||||
prs.save(out)
|
||||
print(out, f"· 질의 {runs}회 · 홈페이지 점검 {d['site_ok']}/{len(d['site'])}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(*sys.argv[1:4])
|
||||
Reference in new issue
Block a user