From 93d3024c222b51787964369e49278a746165c04b Mon Sep 17 00:00:00 2001 From: Jinsoo Shin <59598545+jsshin2022@users.noreply.github.com> Date: Sat, 7 Nov 2026 23:11:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?ui(search):=20=ED=8C=90=EC=A0=95=20?= =?UTF-8?q?=ED=8C=A8=EB=84=90=20=EC=A4=91=EC=8B=AC=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=ED=99=94=EB=A9=B4=20=EA=B0=9C=ED=8E=B8,?= =?UTF-8?q?=20=ED=99=88=20=EA=B2=80=EC=83=89=EC=B0=BD=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 검색창: 아이콘·단축키(/)·큰 입력, 예시는 뉴스식 질문으로 - 가장 가까운 분석의 판정을 큰 판정 패널로 (판정 색 띠 + 95% 범위 그림 + 인용 문장·계보·재현 바로가기) - 분석 결과는 범위 그림이 붙은 카드, 그 밖(이슈·법령·계보·데이터)은 종류 표시가 붙은 한 줄 목록 - 종류 탭에 개수, 결과 없는 탭은 흐리게 · 모바일에서 예시 가로 스크롤 · 다크 모드 · 동작 줄이기 존중 - 홈: 같은 검색창을 첫 화면에, 대화창은 '검색으로 안 풀리면 대화로' 접이식으로 (#ask 로 오면 열림) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EMnmZPBD5PQJW1UQAARN7q --- site/build.py | 13 +++--- site/search.js | 67 ++++++++++++++++++++--------- site/search.py | 57 ++++++++++++++----------- site/style.css | 114 ++++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 186 insertions(+), 65 deletions(-) diff --git a/site/build.py b/site/build.py index 5842fa6..37cf7d8 100644 --- a/site/build.py +++ b/site/build.py @@ -483,13 +483,15 @@ def index_page(topics, policies, issues, datasets, projects=(), answers=(), line

그 정책, 진짜 먹혔을까?

뉴스에서 "효과 있었다", "실패했다"는 말이 나올 때, 공공데이터로 '받은 동네 vs 안 받은 동네'를 비교해 진짜 효과인지 확인하는 곳이에요. 데이터가 모른다고 하면 모른다고 말하는 것까지가 이 사이트의 규칙이에요.

- + + {flow} -
+
+검색으로 안 풀리면 대화로 물어보기 주제 · 데이터 · 분석 계획 초안까지 같이 정리해 드려요
@@ -510,7 +512,8 @@ def index_page(topics, policies, issues, datasets, projects=(), answers=(), line

로컬 Ollama는 OLLAMA_ORIGINS=https://causalinferencelab.github.io로 실행해야 브라우저에서 부를 수 있습니다. AI도 결과를 계산하지 않습니다. 주제·데이터·계획을 함께 정리할 뿐이고, 숫자는 레포의 분석 코드가 냅니다. 법률 자문이 아닙니다.

- + + {proj.personas(e, n_answers, len(datasets))} diff --git a/site/search.js b/site/search.js index 7c46831..cd97e08 100644 --- a/site/search.js +++ b/site/search.js @@ -13,7 +13,7 @@ const $ = (s) => document.querySelector(s); const esc = (s) => String(s == null ? "" : s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]); const norm = (s) => String(s || "").toLowerCase().replace(/\s+/g, ""); - const input = $("#sq"), res = $("#sres"), none = $("#snone"), verdict = $("#verdict"); + const input = $("#sq"), res = $("#sres"), none = $("#snone"), verdict = $("#verdict"), idle = $("#sidle"); const REPO = "https://github.com/CausalInferenceLab/policy-effect-analytics-agent"; let items = [], kind = "", logged = new Set(), timer = null; @@ -40,37 +40,59 @@ if (it.tk && it.tk.split(" ").some((k) => k.length >= 2 && qn.includes(norm(k)))) s += 3; return hit || s >= 3 ? s : 0; } - function row(it) { + const TYPE = { result: "결과", project: "진행 중", issue: "이슈", topic: "주제", law: "법령", lineage: "계보", dataset: "데이터" }; + function card(it) { // 분석 결과: 판정 + 95% 범위 그림 + return `` + + `${esc(it.badge)}${esc(it.title)}` + + `${esc(it.sub)}${esc(it.who)}` + + `${it.g || ""}`; + } + function row(it) { // 그 밖: 한 줄짜리 목록 const ext = /^https?:/.test(it.url); - const badge = it.badge ? `${esc(it.badge)}` : ""; - return `` + - `${badge}${it.who ? `${esc(it.who)}` : ""}` + - `${esc(it.title)}${esc(it.sub)}`; + return `` + + `${TYPE[it.t]}${esc(it.title)}` + + `${esc(it.sub)}${it.badge ? `${esc(it.badge)}` : ""}`; + } + function group(t, xs) { + const draw = t === "result" ? card : row, cls = t === "result" ? "r-list" : "s-rows"; + return `

${KO[t]}${xs.length}

${xs.slice(0, 8).map(draw).join("")}
` + + (xs.length > 8 ? `
${xs.length - 8}개 더 보기
${xs.slice(8).map(draw).join("")}
` : "") + + `
`; + } + function counts(hits) { + document.querySelectorAll(".sf").forEach((b) => { + const n = b.dataset.t ? hits.filter((it) => it.t === b.dataset.t).length : hits.length; + b.querySelector(".n").textContent = hits.length ? n : ""; + b.disabled = !!b.dataset.t && hits.length > 0 && n === 0; + }); } function render(q) { const qn = norm(q), tks = tokens(q); - if (!qn) { res.innerHTML = ""; none.hidden = true; verdict.hidden = true; return 0; } + idle.hidden = !!qn; + if (!qn) { res.innerHTML = ""; none.hidden = true; verdict.hidden = true; counts([]); return 0; } const hits = items.map((it) => [it, score(it, tks, qn)]).filter(([, s]) => s > 0).sort((a, b) => b[1] - a[1]).map(([it]) => it); + counts(hits); const shown = kind ? hits.filter((it) => it.t === kind) : hits; - const groups = ORDER.map((t) => [t, shown.filter((it) => it.t === t)]).filter(([, xs]) => xs.length); - res.innerHTML = groups.map(([t, xs]) => - `

${KO[t]} ${xs.length}

${xs.slice(0, 8).map(row).join("")}
` + - (xs.length > 8 ? `
${xs.length - 8}개 더 보기
${xs.slice(8).map(row).join("")}
` : "") + - `
`).join(""); + res.innerHTML = ORDER.map((t) => [t, shown.filter((it) => it.t === t)]).filter(([, xs]) => xs.length).map(([t, xs]) => group(t, xs)).join(""); const results = hits.filter((it) => it.t === "result"); const propose = `${REPO}/issues/new?template=case-proposal.yml&title=${encodeURIComponent("[작업] " + q.trim().slice(0, 60))}`; $("#snone-propose").href = propose; if (results.length) { const top = results[0]; - verdict.innerHTML = `

이 질문과 가장 가까운 분석

` + - `

${esc(top.title)}

` + - `

${esc(top.badge)} ${esc(top.sub)}

` + - `

판정은 '이 데이터와 이 비교로는' 이라는 조건이 붙은 답입니다. 결과 페이지에서 쓸 수 있는 문장과 한계를 함께 보세요.` + - (results.length > 1 ? ` 비슷한 분석 ${results.length - 1}개가 더 있어요.` : "") + `

`; + verdict.className = "v-panel v-" + top.cls; + verdict.innerHTML = `
가장 가까운 분석의 판정${esc(top.badge)}
` + + `

${esc(top.title)}

${esc(top.sub)}

` + + `
${top.g || ""}
` + + `
인용해도 되는 문장숫자가 나온 길` + + `직접 돌려 보기` + + (results.length > 1 ? `비슷한 분석 ${results.length - 1}개 더` : "") + `
` + + `

판정은 '이 데이터와 이 비교로는'이라는 조건이 붙은 답이에요.

`; verdict.hidden = false; } else if (hits.length) { - verdict.innerHTML = `

아직 이 정책의 효과를 잰 분석은 없어요. 대신 아래 이슈·데이터·계보로 시작할 수 있어요. ` + - `분석 요청하기

`; + verdict.className = "v-panel v-none"; + verdict.innerHTML = `
판정아직 분석 없음
` + + `

이 정책의 효과를 잰 분석은 아직 없어요. 아래 이슈·데이터·계보로 시작할 수 있어요.

` + + `
이 정책 분석 요청하기
`; verdict.hidden = false; } else verdict.hidden = true; none.hidden = hits.length > 0; @@ -94,8 +116,13 @@ const q = new URLSearchParams(location.search).get("q") || ""; input.value = q; if (q) run(q, true); - }).catch(() => { res.innerHTML = '

검색 목록을 불러오지 못했어요. 새로고침해 보세요.

'; }); + }).catch(() => { res.innerHTML = '

검색 목록을 불러오지 못했어요. 새로고침해 보세요.

'; }); input.addEventListener("input", () => run(input.value, false)); + document.addEventListener("keydown", (ev) => { // '/' 로 검색창에 바로 + if (ev.key === "/" && document.activeElement !== input && !/INPUT|TEXTAREA|SELECT/.test(document.activeElement.tagName)) { + ev.preventDefault(); input.focus(); input.select(); + } + }); $("#sform").addEventListener("submit", (ev) => { ev.preventDefault(); run(input.value, true); }); document.querySelectorAll("[data-q]").forEach((a) => a.addEventListener("click", (ev) => { ev.preventDefault(); input.value = a.dataset.q; run(a.dataset.q, true); diff --git a/site/search.py b/site/search.py index e93babe..a2d656a 100644 --- a/site/search.py +++ b/site/search.py @@ -36,7 +36,9 @@ def _j(*parts) -> str: def index(topics, issues, datasets, answers, projects, lineages) -> list[dict]: """검색 항목 목록. kw 는 찾는 데만 쓰는 글(화면에 안 보임).""" - from answers import DESCRIPTIVE_LABEL, VERDICT, card_line + from html import escape + + from answers import DESCRIPTIVE_LABEL, VERDICT, card_line, range_glyph from core.discovery.links import dataset_users, is_auto @@ -57,6 +59,7 @@ def index(topics, issues, datasets, answers, projects, lineages) -> list[dict]: "badge": lab, "cls": cls, "who": "멘토 예시" if a["mentor"] else f"@{a['owner']}", + "g": range_glyph(escape, a), "kw": _j(a["question"], tname.get(a["topic"]), a["owner"], a["case"]), } ) @@ -148,44 +151,48 @@ def write(out_dir, items: list[dict]) -> None: EXAMPLES = [ - "토지거래허가구역", - "기후동행카드", - "출산지원금", - "지역화폐", - "녹색교통", - "대형마트 의무휴업", + ("토허제 풍선효과", "토허제 뒤 옆 동네 집값은?"), + ("기후동행카드", "기후동행카드로 지하철 더 탔나?"), + ("출산지원금", "출산지원금 올리면 아이가 늘었나?"), + ("지역화폐", "상품권 할인 늘리면 결제가 늘었나?"), + ("녹색교통", "노후차 막으니 도심 공기가 좋아졌나?"), + ("대형마트 의무휴업", "마트 쉬는 날 바꾸니 동네 가게는?"), ] def body(e, n_items: int, n_results: int) -> str: chips = "".join( - f'{e(x)}' for x in EXAMPLES + f'{e(label)}' + for q, label in EXAMPLES ) filters = "".join( - f'' + f'' for k, v in TYPE_KO.items() ) return f""" -

그 정책, 진짜 효과였나?

-

뉴스에서 본 정책 이름·지역·키워드를 넣어 보세요. 이미 확인한 분석 결과와 판정, 쓸 수 있는 공공데이터, 데이터가 이어지는 길(계보)을 한 번에 찾아 드려요.

- +
+

그 정책, 진짜 효과였나?

+

뉴스에서 본 정책 이름이나 지역을 넣어 보세요. 이미 확인한 판정, 쓸 수 있는 공공데이터, 숫자가 나온 길까지 한 번에 보여 드려요.

+ + - - -
{chips}
- -
-
{filters}
- + + + +
{chips}
+ +
+
{filters}
+
-
""" diff --git a/site/style.css b/site/style.css index d2569a0..737f4b4 100644 --- a/site/style.css +++ b/site/style.css @@ -537,21 +537,105 @@ details.todo[open] summary { font-weight: 700; color: var(--ink) } @media (max-width: 960px) { ol.path { grid-template-columns: repeat(2, minmax(0, 1fr)) } } @media (max-width: 560px) { ol.path { grid-template-columns: minmax(0, 1fr) } } -/* 통합 검색 */ +/* 통합 검색 — 표지 요소는 판정 패널 하나. 나머지는 조용한 목록 */ .sbox { display: flex; gap: 8px; margin: 18px 0 10px; max-width: 760px } -.sbox input { flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 13px 16px; border: 2px solid var(--ink); border-radius: 12px; background: var(--surface); color: var(--ink) } -.sbox input:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px } -.sbox .btn { border: 0; cursor: pointer; white-space: nowrap } -.home-search { margin-top: 22px } -.s-verdict { margin: 16px 0; border-left: 5px solid var(--accent) } -.s-group { padding: 18px 0 4px } -.s-group h2 { font-size: 17px; margin: 0 0 10px } -.s-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 10px } -.s-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; text-decoration: none; color: inherit } -.s-item:hover { border-color: var(--ink2) } -.s-item b { color: var(--ink); line-height: 1.45 } -.s-item .s-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-height: 4px } -.s-result { border-left: 4px solid var(--accent) } +.sbox input { flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 13px 16px; border: 1px solid var(--hair); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 0 10px 28px -20px rgba(20, 23, 28, .45) } +.sbox input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft) } +.sbox .btn { border: 0; cursor: pointer; white-space: nowrap; border-radius: 14px; padding: 0 22px } +.home-search { max-width: 760px; margin: 26px 0 6px } +details.ask { margin-top: 26px; border-top: 1px solid var(--hair); padding-top: 4px } +details.ask > summary { cursor: pointer; list-style: none; padding: 14px 0; font-weight: 700; color: var(--ink); display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: baseline } +details.ask > summary::-webkit-details-marker { display: none } +details.ask > summary::before { content: "+"; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--sunk); font-weight: 700 } +details.ask[open] > summary::before { content: "−" } +details.ask > summary span { font-weight: 400; font-size: 14px; color: var(--muted) } +@media (max-width: 560px) { .sbox { flex-direction: column } .sbox .btn { padding: 12px 22px } } + +.s-hero { padding: 64px 0 4px; max-width: 820px } +.s-hero h1 { font-size: clamp(34px, 6.2vw, 58px); line-height: 1.08; letter-spacing: -.045em; font-weight: 800; margin: 0 0 16px } +.s-hero .lede { font-size: 17px; max-width: 54ch } +.qbar { position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto auto; align-items: center; margin: 28px 0 14px; + background: var(--surface); border: 1px solid var(--hair); border-radius: 20px; padding: 6px; min-height: 68px; + box-shadow: 0 1px 0 var(--hair), 0 22px 44px -30px rgba(20, 23, 28, .55); transition: border-color .15s, box-shadow .15s } +.qbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft), 0 22px 44px -30px rgba(20, 23, 28, .55) } +.qbar-icon { width: 22px; height: 22px; justify-self: center; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round } +.qbar input { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: clamp(17px, 2.4vw, 21px); font-weight: 700; letter-spacing: -.02em; padding: 12px 6px; min-width: 0 } +.qbar input::placeholder { color: var(--muted); font-weight: 400 } +.qbar input:focus { outline: none } +.qbar input::-webkit-search-cancel-button { cursor: pointer } +.qbar-key { font: 12px var(--mono); color: var(--muted); border: 1px solid var(--hair); border-bottom-width: 2px; border-radius: 6px; padding: 1px 7px; margin-right: 10px } +.qbar:focus-within .qbar-key { visibility: hidden } +.qbar-go { border: 0; border-radius: 14px; background: var(--ink); color: var(--paper); font: inherit; font-weight: 700; font-size: 15px; padding: 0 22px; align-self: stretch; cursor: pointer } +.qbar-go:hover { background: var(--accent); color: #fff } +.qbar-go:focus-visible, .q-chip:focus-visible, .sf:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px } +.q-examples { display: flex; flex-wrap: wrap; gap: 8px } +.q-chip { font-size: 14px; color: var(--ink2); text-decoration: none; background: var(--sunk); border-radius: 10px; padding: 7px 12px; line-height: 1.4 } +.q-chip:hover { background: var(--ink); color: var(--paper) } +@media (max-width: 640px) { + .q-examples { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none } + .q-chip { flex: none } + .qbar { grid-template-columns: 40px minmax(0, 1fr) auto auto; min-height: 60px } + .qbar-go { padding: 0 16px } +} + +.s-body { padding-top: 34px } +.s-filters { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--hair); margin-bottom: 22px; scrollbar-width: none } +.sf { flex: none; border: 0; background: none; font: inherit; font-size: 14.5px; color: var(--muted); padding: 10px 12px 11px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px } +.sf .n { font-size: 12px; margin-left: 5px; color: var(--muted); font-variant-numeric: tabular-nums } +.sf:hover { color: var(--ink) } +.sf[aria-pressed=true] { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink) } +.sf:disabled { opacity: .35; cursor: default } + +.v-panel { --v: var(--warn); --v-bg: var(--warn-bg); position: relative; background: var(--surface); border: 1px solid var(--hair); border-radius: 20px; + padding: 22px 26px 18px 34px; margin: 0 0 26px; overflow: hidden; animation: v-in .22s ease-out } +.v-panel::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 8px; background: var(--v) } +.v-panel.v-go { --v: var(--go); --v-bg: var(--go-bg) } .v-panel.v-stop { --v: var(--stop); --v-bg: var(--stop-bg) } +.v-panel.v-info { --v: var(--accent); --v-bg: var(--accent-soft) } .v-panel.v-none { --v: var(--hair); --v-bg: var(--sunk) } +.v-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap } +.v-label { font-size: 13.5px; color: var(--muted) } +.v-stamp { font-size: clamp(24px, 3.6vw, 34px); font-weight: 800; letter-spacing: -.04em; color: var(--v); line-height: 1.15 } +.v-panel.v-none .v-stamp { color: var(--ink2) } +.v-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 26px; align-items: center; margin-top: 10px } +.v-body h2 { font-size: 19px; line-height: 1.45; margin: 0 0 6px } .v-body h2 a { color: var(--ink); text-decoration: none } .v-body h2 a:hover { text-decoration: underline } +.v-body p, .v-msg { margin: 0; color: var(--ink2); font-size: 15px } +.v-glyph { background: var(--v-bg); border-radius: 14px; padding: 16px 16px 10px } +.v-glyph:empty { display: none } +.v-glyph .glyph svg { height: 46px } +.v-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--hair); font-size: 14.5px; align-items: baseline } +.v-foot a { font-weight: 700; color: var(--ink); text-underline-offset: 3px } +.v-foot span { color: var(--muted); margin-left: auto } +.v-note { margin: 10px 0 0; font-size: 13px; color: var(--muted) } +@keyframes v-in { from { opacity: 0; transform: translateY(6px) } } +@media (prefers-reduced-motion: reduce) { .v-panel { animation: none } } +@media (max-width: 720px) { .v-body { grid-template-columns: 1fr } .v-panel { padding: 20px 18px 16px 26px } .v-foot span { margin-left: 0 } } + +.s-group { padding: 6px 0 22px } +.s-group h2 { font-size: 15px; font-weight: 700; color: var(--ink2); margin: 0 0 10px; display: flex; gap: 8px; align-items: baseline } +.s-group h2 .n { font-size: 13px; color: var(--muted); font-weight: 400 } +.r-list { display: flex; flex-direction: column; gap: 8px } +.r-card { --v: var(--warn); display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 20px; align-items: center; padding: 14px 18px 14px 20px; + background: var(--surface); border: 1px solid var(--hair); border-left: 4px solid var(--v); border-radius: 14px; text-decoration: none; color: inherit } +.r-card.v-go { --v: var(--go) } .r-card.v-stop { --v: var(--stop) } .r-card.v-info { --v: var(--accent) } +.r-card:hover { border-color: var(--ink2); border-left-color: var(--v) } +.r-main { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 0 } +.r-main b { color: var(--ink); line-height: 1.45 } +.r-line { color: var(--ink2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden } +.r-who { color: var(--muted); font-size: 13px } +@media (max-width: 640px) { .r-card { grid-template-columns: 1fr } } +.s-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); column-gap: 28px; border-top: 1px solid var(--hair) } +.s-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--hair); text-decoration: none; color: inherit } +.s-row:hover b { color: var(--accent) } +.s-kind { font-size: 12px; color: var(--muted); text-align: center; background: var(--sunk); border-radius: 6px; padding: 2px 0 } +.t-issue .s-kind { background: var(--r-treat-bg); color: var(--r-treat) } .t-dataset .s-kind { background: var(--r-out-bg); color: var(--r-out) } +.t-lineage .s-kind { background: var(--go-bg); color: var(--go) } .t-project .s-kind { background: var(--warn-bg); color: var(--warn) } +.s-txt { min-width: 0; display: flex; flex-direction: column } +.s-txt b { font-size: 15px; line-height: 1.45; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap } +.s-txt span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap } +.s-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap } +.s-more summary { cursor: pointer; font-size: 14px; color: var(--ink2); padding: 10px 4px } +.s-empty { background: var(--surface); border: 1px dashed var(--hair); border-radius: 20px; padding: 26px } +.s-empty h2 { font-size: 20px; margin: 0 0 6px } +.s-idle p { color: var(--muted); font-size: 15px; margin: 0 } +.s-privacy { color: var(--muted); font-size: 13px; max-width: 74ch; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--hair) } .search-terms { display: flex; flex-wrap: wrap; gap: 6px } .search-terms .chip b { font-weight: 700; margin-left: 4px } -@media (max-width: 560px) { .sbox { flex-direction: column } } From c5aa288998ba51e5f1077b87702e83b977f1a307 Mon Sep 17 00:00:00 2001 From: Jinsoo Shin <59598545+jsshin2022@users.noreply.github.com> Date: Sat, 7 Nov 2026 23:27:15 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat(trust):=20'=EA=B7=B8=EB=9E=98=EB=8F=84?= =?UTF-8?q?=20=EB=A7=90=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=EA=B2=83'=20=EC=A0=84=EB=A9=B4=20=EB=B0=B0=EC=B9=98,=20?= =?UTF-8?q?=EB=89=B4=EC=8A=A4=20=EB=AC=B8=EC=9E=A5=20=EA=B2=80=EC=A6=9D,?= =?UTF-8?q?=20=EA=B2=80=ED=86=A0=20=EB=B0=B0=EC=A7=80,=20=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=ED=99=94=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 판정 옆 한 줄 (answers.takeaway) - 크기를 판별하지 못함 → 배제 범위("±X%보다 큰 변화는 자료와 맞지 않음"), 판단 불가 → 판단할 수 없는 이유, 관측 통계 → 인용 가능한 범위 - 답 페이지 판정 상자와 검색 판정 패널 맨 앞에 2. 뉴스 문장 검증 (search.js checkClaim) - 문장을 붙여 넣으면 가장 가까운 분석과 비교: 뒷받침 / 범위 안 / 결과를 넘어섬 / 결과와 다름 - '효과 없다'·'늘었다/줄었다'·'N%'를 키워드 규칙으로 읽고, 판정과 95% 범위(로그 지표는 %)로 판단 - 결과 안에서 말할 수 있는 문장(이렇게 쓰세요) 제안, 공식 팩트체크 아님을 고지 - usage_rules 로 결과 페이지와 같은 규칙을 공유 3. 검토 배지 (docs/ops/review-checklist.md) - 작성자 아닌 사람이 여덟 항목 확인 → projects.yaml reviewed_by → '검토됨' 배지·신뢰 항목·다음 할 일 - PR 템플릿에 검토 체크 항목 4. 구조화 데이터 (answers.jsonld) - 모든 답 페이지에 schema.org Dataset(CSV 배포 포함) - ClaimReview 는 사람이 projects.yaml claims 에 실제 주장·출처·평가를 적었을 때만 (질문을 주장처럼 꾸미지 않음) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EMnmZPBD5PQJW1UQAARN7q --- .github/PULL_REQUEST_TEMPLATE.md | 1 + README.md | 2 +- catalog/projects.yaml | 4 + docs/ops/review-checklist.md | 23 +++++ site/answers.py | 160 ++++++++++++++++++++++++++++++- site/build.py | 4 +- site/impact.py | 1 + site/quality.py | 21 ++++ site/search.js | 61 +++++++++++- site/search.py | 22 ++++- site/style.css | 18 ++++ tests/test_trust_claims.py | 98 +++++++++++++++++++ 12 files changed, 407 insertions(+), 8 deletions(-) create mode 100644 docs/ops/review-checklist.md create mode 100644 tests/test_trust_claims.py diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 384dfb2..5254d9e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -15,6 +15,7 @@ - [ ] `make check` (ruff + pytest)가 통과합니다 - [ ] 다른 사람의 폴더나 `core/`를 (합의 없이) 수정하지 않았습니다 - [ ] 원자료·가공 데이터 파일을 커밋하지 않았습니다 (시뮬레이션·조례 목록 제외) +- [ ] 결과 PR이면 작성자가 아닌 리뷰어가 [검토 체크리스트](docs/ops/review-checklist.md) 여덟 항목을 리뷰 댓글로 확인했습니다 ## 리뷰어에게 diff --git a/README.md b/README.md index 4bd5e9e..aeff5c4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ "효과 있었다", "실패했다"는 말이 나올 때 **진짜 효과인지 확인하는 장치**입니다. 정책을 받은 동네와 안 받은 동네를 공공데이터로 비교하고, 데이터가 모르면 "판단 불가"라고 정직하게 말합니다. 질문부터 데이터·계보·분석·대시보드까지 전부 오픈소스입니다. -🔎 **[정책 이름으로 찾기](https://causalinferencelab.github.io/policy-effect-analytics-agent/search.html)** — 이미 확인한 결과와 판정, 쓸 수 있는 공공데이터, 데이터 계보가 한 번에 나옵니다. 결과가 없으면 그 자리에서 분석을 요청할 수 있습니다. +🔎 **[정책 이름으로 찾기](https://causalinferencelab.github.io/policy-effect-analytics-agent/search.html)** — 이미 확인한 결과와 판정, 쓸 수 있는 공공데이터, 데이터 계보가 한 번에 나옵니다. 결과가 없으면 그 자리에서 분석을 요청할 수 있습니다. **뉴스 문장을 통째로 붙여 넣으면** 그 문장이 결과로 뒷받침되는지(뒷받침 · 범위 안 · 결과를 넘어섬 · 결과와 다름) 보여 줍니다. [![사이트 열기](https://img.shields.io/badge/사이트-열기-1d4e89)](https://causalinferencelab.github.io/policy-effect-analytics-agent/) [![분석 결과](https://img.shields.io/badge/분석_결과-보기-1e6a4d)](https://causalinferencelab.github.io/policy-effect-analytics-agent/results.html) diff --git a/catalog/projects.yaml b/catalog/projects.yaml index d9583b7..3194bf7 100644 --- a/catalog/projects.yaml +++ b/catalog/projects.yaml @@ -4,6 +4,10 @@ # plan.yaml → 계획 · fetch.py → 수집 · flow_log.json → 분석 · discussion.md(템플릿과 다르면) → 해석 # reproduced_by: [GitHub ID, ...] — 다른 참여자가 make flow 로 같은 판정을 얻었으면 재현 이슈를 확인하고 추가합니다. # 답 페이지의 '이 결과를 얼마나 믿을 수 있나'와 카드의 '교차 재현됨' 배지로 나옵니다. +# reviewed_by: [GitHub ID, ...] — 작성자가 아닌 사람이 docs/ops/review-checklist.md 여덟 항목을 확인했으면 추가합니다('검토됨' 배지). +# claims: 뉴스·발표에서 나온 구체적인 주장을 이 결과로 검토했을 때만 적습니다 → 답 페이지에 팩트체크 표준 마크업(ClaimReview) +# - text: "주장 문장 그대로" by: "말한 사람·기관" url: "주장이 실린 곳" date: YYYY-MM-DD +# rating: "결과와 맞음" | "범위 안" | "결과를 넘어섬" | "결과와 다름" (검토한 사람이 고름) version: 1 projects: - case: sgim49697-ops-gangnam-bus-2024 diff --git a/docs/ops/review-checklist.md b/docs/ops/review-checklist.md new file mode 100644 index 0000000..8840e48 --- /dev/null +++ b/docs/ops/review-checklist.md @@ -0,0 +1,23 @@ +# 결과 검토 체크리스트 + +사이트의 판정은 '이 데이터와 이 비교로는'이라는 조건이 붙은 답입니다. 작성자가 아닌 사람이 아래 여덟 가지를 확인하면 그 결과에 **검토됨** 배지가 붙습니다. +검토는 결과가 맞다는 보증이 아니라, 결과가 **자기 규칙을 지켰다**는 확인입니다. 숫자를 다시 돌려 보는 것은 [교차 재현](../../.github/ISSUE_TEMPLATE/reproduction.yml)이 따로 맡습니다. + +| # | 확인할 것 | 어디서 보나 | 통과 기준 | +|---|---|---|---| +| 1 | 계획이 결과보다 먼저인가 | 답 페이지 '이 결과를 얼마나 믿을 수 있나' · `git log -- cases/<케이스>/plan.yaml` | 계획 먼저 커밋, 또는 결과 뒤 수정 이유가 discussion.md '계획에서 바뀐 것'에 있음 | +| 2 | 처치 시점이 공식 문서로 확인되나 | plan.yaml `treatment.definition` · README | 법령·고시·보도자료·조례 중 하나의 링크 | +| 3 | 비교 대상이 결과를 보고 고른 것이 아닌가 | plan.yaml `control.rationale` · fetch.py | 선정 규칙이 코드나 문장으로 고정돼 있음 | +| 4 | 데이터 이용 조건이 공개에 맞나 | plan.yaml `data_sources[].license` | 공공누리 1유형·이용허락 제한 없음, 또는 원자료를 커밋하지 않음 | +| 5 | 원자료·개인정보·키가 레포에 없나 | PR 파일 목록 | `data/`·`.env`·키 없음 | +| 6 | 판정 문장이 판정을 넘지 않나 | discussion.md '결과를 한 문장으로' · README | '크기를 판별하지 못함'·'판단 불가'를 '효과 없음'으로 쓰지 않음, 인과 단정 없음 | +| 7 | 한계가 적혀 있나 | discussion.md · plan.yaml `cautions` | 동시에 일어난 다른 사건, 대조군 오염, 측정 문제 중 해당하는 것 | +| 8 | 지표 정의가 재현 가능한가 | plan.yaml `outcomes[].definition` · fetch.py | 다른 사람이 같은 표를 만들 수 있을 만큼 구체적임 | + +## 절차 + +1. 결과 PR에서 위 표를 복사해 PR 리뷰 댓글에 ✅/❌로 채웁니다. ❌가 있으면 작성자가 고친 뒤 다시 봅니다. +2. 여덟 개가 모두 ✅면 `catalog/projects.yaml`의 그 케이스에 `reviewed_by: [내 GitHub ID]`를 더하는 커밋을 같은 PR에 올립니다. +3. 사이트가 다시 빌드되면 결과 카드·검색 판정 패널에 **검토됨**, 답 페이지 신뢰 항목에 '검토 · 통과'가 나옵니다. + +작성자 본인은 자기 결과를 검토할 수 없습니다. 멘토 예시도 같은 규칙을 따릅니다. diff --git a/site/answers.py b/site/answers.py index 7a85bc6..8b04efd 100644 --- a/site/answers.py +++ b/site/answers.py @@ -381,6 +381,10 @@ def load_answers() -> list[dict]: )[:10], "page": f"answers/{case.name}.html", "reproduced_by": list(meta.get("reproduced_by") or []), + "reviewed_by": list(meta.get("reviewed_by") or []), + "claims": [ + c for c in meta.get("claims") or [] if isinstance(c, dict) and c.get("text") + ], "prereg": prereg(case), **read_discussion(case), } @@ -569,6 +573,8 @@ def card(e, a: dict, topics_by_id: dict, up: str = "") -> str: tags.append('시뮬레이션 데이터 결과') if a["mentor"]: tags.append('멘토 예시') + if a.get("reviewed_by"): + tags.append('검토됨') if a.get("reproduced_by"): tags.append('교차 재현됨') if (a.get("prereg") or {}).get("level") == "go": @@ -634,7 +640,56 @@ def trust_block(e, a: dict) -> str:

교차 재현을 하셨나요? 재현 기록 남기기

""" -def _usage(e, a: dict) -> str: +def primary_range(a: dict) -> dict | None: + """주 지표의 추정치·95% 범위 (로그 지표는 % 로). 문장 검증·검색 패널이 쓴다.""" + r = next( + (x for x in a["results"] if x.get("est") is not None and x.get("lo") is not None), None + ) + if not r: + return None + col, unit = r.get("col") or "", r.get("unit") + pct = interpret.is_log(col, unit) + + def tx(v): + return round((math.exp(v) - 1) * 100 if pct else v, 4) + + return { + "name": r.get("name") or col, + "est": tx(r["est"]), + "lo": tx(r["lo"]), + "hi": tx(r["hi"]), + "unit": "%" if pct else (unit or ""), + } + + +def takeaway(a: dict) -> dict | None: + """판정 바로 옆에 둘 한 줄: '모른다'만 남기지 않고 그래도 말할 수 있는 것을 앞에 둔다.""" + if a.get("execution_kind") == "descriptive_only": + return { + "head": "말할 수 있는 것", + "text": "연도별 관측값은 지역·연도·단위와 함께 인용할 수 있어요. 정책 효과는 추정하지 않았어요.", + } + v = a["verdict"] + if v == "conditional": + r = next((r for r in a["results"] if (r.get("said") or {}).get("rule_out")), None) + if r: + return {"head": "그래도 말할 수 있는 것", "text": r["said"]["rule_out"]} + return None + if v == "not_identified": + why = ", ".join(dict.fromkeys(w for r in a["results"] for w in r.get("why") or [])) + return {"head": "판단할 수 없는 이유", "text": why or "설계 조건을 채우지 못했어요"} + if v == "identified": + p = next(iter(a["results"]), None) + if p: + return { + "head": "말할 수 있는 것", + "text": f"{p['name']} {p['effect']} (95% 범위 {p['range']})", + } + return None + + +def usage_rules(a: dict) -> tuple[list[str], list[str]]: + """이렇게 쓰세요 / 이렇게 쓰면 안 됩니다 — 결과 페이지와 문장 검증이 같은 규칙을 쓴다.""" v = a["verdict"] p = next(iter(a["results"]), None) eff = "" @@ -672,6 +727,13 @@ def _usage(e, a: dict) -> str: ) do = [f'"이 설계로는 효과를 판단할 수 없다. 이유: {reasons}."'] dont = ["표의 숫자·p값 인용 — 진단용입니다", "'효과가 있다' 또는 '없다'"] + return do, dont + + +def _usage(e, a: dict) -> str: + v = a["verdict"] + descriptive = a.get("execution_kind") == "descriptive_only" + do, dont = usage_rules(a) cite = ( f"{a['title']} — 판정: {DESCRIPTIVE_LABEL if descriptive else VERDICT.get(v, (v,))[0]}. 출처: 정책 효과 분석 플랫폼" f"(가짜연구소 인과추론팀 오픈소스), {a['finished'] or '날짜 미상'} 실행, {SITE}/{a['page']} · 공식 평가 아님" @@ -739,7 +801,7 @@ def _descriptive_page(e, a: dict, topics_by_id: dict) -> str:

{e(a["title"])}

{e(a["question"])}

{DESCRIPTIVE_LABEL} -

연도별 관측값을 정리했습니다. 인과효과 추정은 실행하지 않아 정책 효과를 판단할 수 없습니다.

{author}
+

연도별 관측값을 정리했습니다. 인과효과 추정은 실행하지 않아 정책 효과를 판단할 수 없습니다.

{takeaway_html(e, a)}{author} {_usage(e, a)}

관측 통계

{changed}
{figs}

연도별 관측값

{header}{rows}
@@ -757,6 +819,99 @@ def _descriptive_page(e, a: dict, topics_by_id: dict) -> str: """ +CLAIM_RATINGS = {"결과와 맞음": 4, "범위 안": 3, "결과를 넘어섬": 2, "결과와 다름": 1} + + +def jsonld(a: dict) -> str: + """검색엔진용 구조화 데이터. 결과 표(CSV)는 Dataset 으로, 사람이 적은 claims 가 있을 때만 ClaimReview. + + ClaimReview 는 '누군가 실제로 한 주장'을 검토했을 때만 쓴다(질문을 주장처럼 꾸미지 않는다). + """ + org = { + "@type": "Organization", + "name": "가짜연구소 인과추론팀 (정책 효과 분석 플랫폼)", + "url": SITE, + } + lab = ( + DESCRIPTIVE_LABEL + if a.get("execution_kind") == "descriptive_only" + else VERDICT.get(a["verdict"], (a["verdict"] or "-",))[0] + ) + csv_name = ( + f"{a['case']}-descriptive.csv" + if a.get("execution_kind") == "descriptive_only" + else f"{a['case']}.csv" + ) + items = [ + { + "@context": "https://schema.org", + "@type": "Dataset", + "name": a["title"], + "description": f"{a['question'] or a['title']} — 판정: {lab}. 공공데이터로 정책을 받은 곳과 안 받은 곳을 비교한 결과표. 공식 평가가 아닙니다.", + "url": f"{SITE}/{a['page']}", + "creator": org, + "isAccessibleForFree": True, + "inLanguage": "ko", + "keywords": ["정책 효과", "공공데이터", "인과추론", lab], + "variableMeasured": [r["name"] for r in a["results"]][:6] or None, + "dateModified": a["finished"] or None, + "distribution": [ + { + "@type": "DataDownload", + "encodingFormat": "text/csv", + "contentUrl": f"{SITE}/answers/{csv_name}", + } + ], + } + ] + for c in a.get("claims") or []: + rating = c.get("rating") + if rating not in CLAIM_RATINGS: + continue + items.append( + { + "@context": "https://schema.org", + "@type": "ClaimReview", + "url": f"{SITE}/{a['page']}", + "claimReviewed": c["text"], + "author": org, + "datePublished": a["finished"] or None, + "itemReviewed": { + "@type": "Claim", + "author": {"@type": "Organization", "name": c.get("by", "")}, + "datePublished": c.get("date"), + "appearance": {"@type": "CreativeWork", "url": c.get("url")} + if c.get("url") + else None, + }, + "reviewRating": { + "@type": "Rating", + "ratingValue": CLAIM_RATINGS[rating], + "bestRating": 4, + "worstRating": 1, + "alternateName": rating, + }, + } + ) + + def clean(x): + if isinstance(x, dict): + return {k: clean(v) for k, v in x.items() if v not in (None, "", [])} + if isinstance(x, list): + return [clean(v) for v in x] + return x + + body = json.dumps(clean(items if len(items) > 1 else items[0]), ensure_ascii=False) + return '" + + +def takeaway_html(e, a: dict) -> str: + t = takeaway(a) + if not t: + return "" + return f'
{e(t["head"])}

{e(t["text"])}

' + + def page_body(e, a: dict, topics_by_id: dict, datasets_by_url: dict) -> str: if a.get("execution_kind") == "descriptive_only": return _descriptive_page(e, a, topics_by_id) @@ -831,6 +986,7 @@ def page_body(e, a: dict, topics_by_id: dict, datasets_by_url: dict) -> str:
{e(lab)}

{e(VERDICT_PLAIN.get(a["verdict"], ""))}

+{takeaway_html(e, a)} {author}
파이프라인 자동 요약 보기

{e(auto_summary(a))}

{_usage(e, a)} diff --git a/site/build.py b/site/build.py index 37cf7d8..0d86264 100644 --- a/site/build.py +++ b/site/build.py @@ -122,6 +122,7 @@ def page( desc: str | None = None, path: str | None = None, image: str | None = None, + head: str = "", ) -> str: """공통 틀. path(사이트 안 경로)를 주면 공유 미리보기(Open Graph)용 주소·그림을 붙인다.""" up = "../" * depth @@ -149,7 +150,7 @@ def page( {e(title)} {og} - +{head} @@ -1158,6 +1159,7 @@ def main() -> None: desc=ans.share_text(a), path=a["page"], image=f"cases/{a['case']}/{fig}" if fig else None, + head=ans.jsonld(a), ), encoding="utf-8", ) diff --git a/site/impact.py b/site/impact.py index d76b437..864dc1e 100644 --- a/site/impact.py +++ b/site/impact.py @@ -30,6 +30,7 @@ "search": "결과 검색", "home-search": "홈 검색창 사용", "search-propose": "검색 후 분석 요청", + "claim-check": "뉴스 문장 검증", "reproduce": "재현 기록 열기", "flow-stage": "홈 흐름 띠의 단계 누름", } diff --git a/site/quality.py b/site/quality.py index 3c1f541..d0beb23 100644 --- a/site/quality.py +++ b/site/quality.py @@ -8,6 +8,7 @@ 얕은 clone(Actions 기본)이면 기록이 없으므로 None (화면에서 빠진다). 2. 교차 재현: catalog/projects.yaml 의 reproduced_by (다른 참여자가 make flow 로 같은 판정을 얻었음). 3. 작성자 해석: discussion.md 에 '결과를 한 문장으로'가 있는가. +5. 검토: catalog/projects.yaml 의 reviewed_by (작성자 외의 사람이 검토 체크리스트로 확인했음). 4. 다음 할 일: 위 항목과 진행 단계로 참여자에게 보여 줄 할 일 목록. """ @@ -103,6 +104,24 @@ def checks(a: dict) -> list[tuple[str, str, str]]: out.append( ("info", "사전 등록 · 기록 확인 안 됨", "이 빌드에서는 git 기록을 읽지 못했습니다.") ) + rev = a.get("reviewed_by") or [] + if rev: + who = ", ".join(f"@{x}" for x in rev) + out.append( + ( + "go", + "검토 · 통과", + f"{who} 이(가) 검토 체크리스트(docs/ops/review-checklist.md)로 확인했습니다.", + ) + ) + else: + out.append( + ( + "warn", + "검토 · 아직 없음", + "작성자 외의 사람이 검토 체크리스트로 확인하지 않았습니다.", + ) + ) rep = a.get("reproduced_by") or [] if rep: who = ", ".join(f"@{x}" for x in rep) @@ -150,6 +169,8 @@ def next_steps(p: dict, a: dict | None, registered: bool) -> list[str]: if a is not None: if st[3] and not a.get("has_one_line"): todo.append("discussion.md 에 '## 결과를 한 문장으로' 추가") + if not a.get("reviewed_by"): + todo.append("검토 요청 (docs/ops/review-checklist.md)") if not a.get("reproduced_by"): todo.append("다른 참여자에게 교차 재현 요청") pr = a.get("prereg") diff --git a/site/search.js b/site/search.js index cd97e08..d8792f8 100644 --- a/site/search.js +++ b/site/search.js @@ -59,6 +59,60 @@ (xs.length > 8 ? `
${xs.length - 8}개 더 보기
${xs.slice(8).map(draw).join("")}
` : "") + `
`; } + // ─── 문장 검증: 뉴스 문장이 결과가 말할 수 있는 범위를 넘는지 (키워드 규칙) ─────────── + const NULL_RE = /효과\s*(가|는|도)?\s*없|변화\s*(가|는|도)?\s*없|아무\s*변화|그대로였|실패|소용\s*없|안\s*먹혔|못\s*했|못했|헛수고/; + const UP_RE = /늘었|늘어|증가|올랐|오르|상승|개선|좋아|활성|살아났|많아/; + const DOWN_RE = /줄었|줄어|감소|떨어|내렸|하락|잡혔|잡았|억제|낮아|안정|적어/; + const EFFECT_RE = /효과|덕분|때문|성공|먹혔|통했|영향/; + const PCT_RE = /([+-]?\d+(?:\.\d+)?)\s*%/; + function looksLikeClaim(q) { + const t = q.trim(); + return t.length >= 12 && /\s/.test(t) && (NULL_RE.test(t) || UP_RE.test(t) || DOWN_RE.test(t) || EFFECT_RE.test(t) || PCT_RE.test(t)); + } + const RANK = { ok: 0, inside: 1, beyond: 2, conflict: 3 }; + const MARK = { ok: ["뒷받침", "go"], inside: ["범위 안", "info"], beyond: ["결과를 넘어섬", "warn"], conflict: ["결과와 다름", "stop"] }; + function checkClaim(q, r) { + const parts = [], v = r.v, pr = r.pr; + const isNull = NULL_RE.test(q), up = UP_RE.test(q), down = DOWN_RE.test(q) && !up, dir = up ? 1 : down ? -1 : 0; + const effect = !isNull && (dir !== 0 || EFFECT_RE.test(q)); + if (isNull) { + if (v === "identified") parts.push(["conflict", "'효과가 없다'고 했지만, 이 분석은 효과 근거가 있다고 판정했어요."]); + else if (v === "conditional") parts.push(["beyond", "판별하지 못한 것과 효과가 없는 것은 달라요. 이 자료로는 있다·없다 모두 단정할 수 없어요."]); + else parts.push(["beyond", "이 분석은 효과를 판단하지 않았어요(판단 불가·관측 통계). '없다'고 말할 근거도 없어요."]); + } else if (effect) { + if (v === "identified" && pr) { + const sign = Math.sign(pr.est); + if (dir && dir !== sign) parts.push(["conflict", `방향이 반대예요. 분석의 추정치는 ${pr.est > 0 ? "증가" : "감소"} 쪽이에요.`]); + else parts.push(["ok", "효과가 있었다는 말은 이 분석의 판정과 맞아요. 같은 지역·기간·지표에 한정해서 쓰세요."]); + } else if (v === "conditional") parts.push(["beyond", "효과가 '있었다'고 말할 근거는 부족해요. 이 자료로는 효과가 있었는지 판별하지 못했어요."]); + else if (v === "descriptive") parts.push(["beyond", "관측값의 변화는 인용할 수 있지만, 정책 '때문'이라고 할 근거는 없어요(효과 미추정)."]); + else parts.push(["beyond", "이 설계로는 효과를 판단할 수 없었어요. 원인이라고 말할 근거가 없어요."]); + } + const m = q.match(PCT_RE); + if (m) { + let n = parseFloat(m[1]); + if (!/^[+-]/.test(m[1]) && down) n = -n; + if (!pr || pr.unit !== "%") parts.push(["beyond", v === "not_identified" ? "판단 불가 결과의 숫자는 진단용이라 비교하지 않아요." : "이 분석의 주 지표는 %로 비교할 수 없어요."]); + else if (n < pr.lo || n > pr.hi) parts.push(["conflict", `${n > 0 ? "+" : ""}${n}%는 이 자료의 95% 범위(${pr.lo.toFixed(1)}% ~ ${pr.hi.toFixed(1)}%) 밖이라 자료와 맞지 않아요.`]); + else parts.push(["inside", `${n > 0 ? "+" : ""}${n}%는 95% 범위(${pr.lo.toFixed(1)}% ~ ${pr.hi.toFixed(1)}%) 안이에요. ` + (v === "identified" ? "자료와 맞는 크기예요." : "자료와 어긋나지는 않지만, 그 크기로 판별된 것은 아니에요.")]); + } + if (!parts.length) parts.push(["inside", "문장에서 효과·방향·크기 주장을 찾지 못했어요. 아래 결과에서 직접 확인해 보세요."]); + const worst = parts.reduce((a, b) => (RANK[b[0]] > RANK[a[0]] ? b : a))[0]; + return { worst, parts }; + } + function renderClaim(q, results) { + const box = $("#claim"); + if (!looksLikeClaim(q) || !results.length) { box.hidden = true; return; } + const r = results[0], c = checkClaim(q, r), [lab, cls] = MARK[c.worst]; + box.className = "c-panel c-" + cls; + box.innerHTML = `
이 문장, 분석 결과로 뒷받침되나요?${lab}
` + + `
${esc(q)}
` + + `` + + (r.rules && r.rules[0] && r.rules[0][0] ? `
이렇게 쓰면 결과 안에서 말할 수 있어요

${esc(r.rules[0][0])}

` : "") + + `

비교한 분석: ${esc(r.title)}. 키워드 규칙으로 읽은 결과라, 문장의 지역·기간·지표가 이 분석과 같은지는 직접 확인하세요. 법률 자문이나 공식 팩트체크가 아니에요.

`; + box.hidden = false; + if (window.track) window.track("claim-check"); + } function counts(hits) { document.querySelectorAll(".sf").forEach((b) => { const n = b.dataset.t ? hits.filter((it) => it.t === b.dataset.t).length : hits.length; @@ -69,20 +123,23 @@ function render(q) { const qn = norm(q), tks = tokens(q); idle.hidden = !!qn; - if (!qn) { res.innerHTML = ""; none.hidden = true; verdict.hidden = true; counts([]); return 0; } + if (!qn) { res.innerHTML = ""; none.hidden = true; verdict.hidden = true; $("#claim").hidden = true; counts([]); return 0; } const hits = items.map((it) => [it, score(it, tks, qn)]).filter(([, s]) => s > 0).sort((a, b) => b[1] - a[1]).map(([it]) => it); counts(hits); const shown = kind ? hits.filter((it) => it.t === kind) : hits; res.innerHTML = ORDER.map((t) => [t, shown.filter((it) => it.t === t)]).filter(([, xs]) => xs.length).map(([t, xs]) => group(t, xs)).join(""); const results = hits.filter((it) => it.t === "result"); + renderClaim(q, results); const propose = `${REPO}/issues/new?template=case-proposal.yml&title=${encodeURIComponent("[작업] " + q.trim().slice(0, 60))}`; $("#snone-propose").href = propose; if (results.length) { const top = results[0]; verdict.className = "v-panel v-" + top.cls; - verdict.innerHTML = `
가장 가까운 분석의 판정${esc(top.badge)}
` + + verdict.innerHTML = `
가장 가까운 분석의 판정${esc(top.badge)}` + + (top.rev ? `검토됨` : `검토 전`) + `
` + `

${esc(top.title)}

${esc(top.sub)}

` + `
${top.g || ""}
` + + (top.ro ? `
${esc(top.ro.head)}

${esc(top.ro.text)}

` : "") + `
인용해도 되는 문장숫자가 나온 길` + `직접 돌려 보기` + (results.length > 1 ? `비슷한 분석 ${results.length - 1}개 더` : "") + `
` + diff --git a/site/search.py b/site/search.py index a2d656a..9c0d6a1 100644 --- a/site/search.py +++ b/site/search.py @@ -38,7 +38,15 @@ def index(topics, issues, datasets, answers, projects, lineages) -> list[dict]: """검색 항목 목록. kw 는 찾는 데만 쓰는 글(화면에 안 보임).""" from html import escape - from answers import DESCRIPTIVE_LABEL, VERDICT, card_line, range_glyph + from answers import ( + DESCRIPTIVE_LABEL, + VERDICT, + card_line, + primary_range, + range_glyph, + takeaway, + usage_rules, + ) from core.discovery.links import dataset_users, is_auto @@ -60,6 +68,12 @@ def index(topics, issues, datasets, answers, projects, lineages) -> list[dict]: "cls": cls, "who": "멘토 예시" if a["mentor"] else f"@{a['owner']}", "g": range_glyph(escape, a), + # 판정 패널 · 문장 검증용 + "v": "descriptive" if desc else a["verdict"], + "ro": takeaway(a), + "pr": None if desc or a["verdict"] == "not_identified" else primary_range(a), + "rules": usage_rules(a), + "rev": bool(a.get("reviewed_by")), "kw": _j(a["question"], tname.get(a["topic"]), a["owner"], a["case"]), } ) @@ -150,6 +164,7 @@ def write(out_dir, items: list[dict]) -> None: ) +CLAIM_EXAMPLE = "토지거래허가구역 지정 뒤 옆 동네 집값이 20% 넘게 올랐다" EXAMPLES = [ ("토허제 풍선효과", "토허제 뒤 옆 동네 집값은?"), ("기후동행카드", "기후동행카드로 지하철 더 탔나?"), @@ -179,10 +194,13 @@ def body(e, n_items: int, n_results: int) -> str: -
{chips}
+
{chips}
+

뉴스 문장을 통째로 붙여 넣어도 돼요. 그 문장이 분석 결과로 뒷받침되는지 봐 드려요. +예: "{e(CLAIM_EXAMPLE)}"

{filters}
+