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://causalinferencelab.github.io/policy-effect-analytics-agent/) [](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["question"])}
연도별 관측값을 정리했습니다. 인과효과 추정은 실행하지 않아 정책 효과를 판단할 수 없습니다.
{author}연도별 관측값을 정리했습니다. 인과효과 추정은 실행하지 않아 정책 효과를 판단할 수 없습니다.
{takeaway_html(e, a)}{author} {_usage(e, a)}{e(t["text"])}
{e(VERDICT_PLAIN.get(a["verdict"], ""))}
+{takeaway_html(e, a)} {author}{e(auto_summary(a))}
뉴스에서 "효과 있었다", "실패했다"는 말이 나올 때, 공공데이터로 '받은 동네 vs 안 받은 동네'를 비교해 진짜 효과인지 확인하는 곳이에요. 데이터가 모른다고 하면 모른다고 말하는 것까지가 이 사이트의 규칙이에요.
- + + {flow} -로컬 Ollama는 OLLAMA_ORIGINS=https://causalinferencelab.github.io로 실행해야 브라우저에서 부를 수 있습니다.
AI도 결과를 계산하지 않습니다. 주제·데이터·계획을 함께 정리할 뿐이고, 숫자는 레포의 분석 코드가 냅니다. 법률 자문이 아닙니다.
${esc(q)}` + + `
${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; + 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; $("#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; - const groups = ORDER.map((t) => [t, shown.filter((it) => it.t === t)]).filter(([, xs]) => xs.length); - res.innerHTML = groups.map(([t, xs]) => - `이 질문과 가장 가까운 분석
` + - `${esc(top.badge)} ${esc(top.sub)}
` + - `판정은 '이 데이터와 이 비교로는' 이라는 조건이 붙은 답입니다. 결과 페이지에서 쓸 수 있는 문장과 한계를 함께 보세요.` + - (results.length > 1 ? ` 비슷한 분석 ${results.length - 1}개가 더 있어요.` : "") + `
`; + verdict.className = "v-panel v-" + top.cls; + verdict.innerHTML = `${esc(top.sub)}
${esc(top.ro.text)}
판정은 '이 데이터와 이 비교로는'이라는 조건이 붙은 답이에요.
`; 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 +173,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..9c0d6a1 100644 --- a/site/search.py +++ b/site/search.py @@ -36,7 +36,17 @@ 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, + primary_range, + range_glyph, + takeaway, + usage_rules, + ) from core.discovery.links import dataset_users, is_auto @@ -57,6 +67,13 @@ 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), + # 판정 패널 · 문장 검증용 + "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"]), } ) @@ -147,45 +164,53 @@ def write(out_dir, items: list[dict]) -> None: ) +CLAIM_EXAMPLE = "토지거래허가구역 지정 뒤 옆 동네 집값이 20% 넘게 올랐다" 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""" -뉴스에서 본 정책 이름·지역·키워드를 넣어 보세요. 이미 확인한 분석 결과와 판정, 쓸 수 있는 공공데이터, 데이터가 이어지는 길(계보)을 한 번에 찾아 드려요.
- +뉴스 문장을 통째로 붙여 넣어도 돼요. 그 문장이 분석 결과로 뒷받침되는지 봐 드려요. +예: "{e(CLAIM_EXAMPLE)}"
그게 바로 다음 분석 거리예요. 무엇이 궁금한지 남겨 주면 참여자가 데이터부터 찾아봅니다.
분석 결과 {n_results}개 · 검색 항목 {n_items}개를 이 브라우저 안에서 찾습니다.
-검색어는 서버에 저장하지 않습니다. 이용 통계가 켜진 경우에만 숫자·이메일·주소를 지운 짧은 검색어(30자)의 횟수를 쿠키 없이 셉니다(GoatCounter, 브라우저의 '추적 안 함'을 따름). -많이 찾았는데 결과가 없던 검색어는 성과에 공개되고 다음 분석 주제의 후보가 됩니다.
+지금 찾을 수 있는 것: 분석 결과 {n_results}개를 포함해 이슈·법령·계보·공공데이터 {n_items}개.
검색은 이 브라우저 안에서만 합니다. 이용 통계가 켜진 경우에만 숫자·이메일·주소를 지운 30자 이내 검색어의 횟수를 쿠키 없이 셉니다(GoatCounter, '추적 안 함'을 따름). +결과가 없던 검색어는 성과에 공개되어 다음 분석 주제의 후보가 됩니다.
""" diff --git a/site/style.css b/site/style.css index d2569a0..2122160 100644 --- a/site/style.css +++ b/site/style.css @@ -537,21 +537,123 @@ 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 } } + +/* 판정 옆 '그래도 말할 수 있는 것' */ +.takeaway { margin: 12px 0; padding: 12px 16px; border-radius: 12px; background: var(--sunk) } +.takeaway span { display: block; font-size: 13px; font-weight: 700; color: var(--ink2); margin-bottom: 2px } +.takeaway p { margin: 0; font-size: 15.5px; color: var(--ink); line-height: 1.6 } + +/* 문장 검증 패널 */ +.q-hint { font-size: 14px; color: var(--muted); margin: 14px 0 0 } +.q-hint a { color: var(--ink2) } +.c-panel { --c: var(--accent); background: var(--surface); border: 1px solid var(--hair); border-top: 6px solid var(--c); border-radius: 20px; padding: 20px 26px; margin: 0 0 18px; animation: v-in .22s ease-out } +.c-panel.c-go { --c: var(--go) } .c-panel.c-warn { --c: var(--warn) } .c-panel.c-stop { --c: var(--stop) } +.c-head { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap } +.c-stamp { font-size: clamp(22px, 3.2vw, 30px); font-weight: 800; letter-spacing: -.04em; color: var(--c) } +.c-panel blockquote { margin: 12px 0; padding: 4px 0 4px 14px; border-left: 3px solid var(--hair); font-size: 17px; color: var(--ink) } +.c-parts { list-style: none; padding: 0; margin: 0 0 6px; display: flex; flex-direction: column; gap: 8px } +.c-parts li { display: flex; gap: 10px; align-items: baseline; font-size: 15px; color: var(--ink2) } +.c-parts .badge { flex: none } +@media (prefers-reduced-motion: reduce) { .c-panel { animation: none } } diff --git a/tests/test_trust_claims.py b/tests/test_trust_claims.py new file mode 100644 index 0000000..96cab7d --- /dev/null +++ b/tests/test_trust_claims.py @@ -0,0 +1,98 @@ +"""판정 옆 '말할 수 있는 것', 검토 배지, 구조화 데이터(Dataset · ClaimReview).""" + +import json +import re +import sys +from html import escape +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / "site")) + +import answers as ans # noqa: E402 +from quality import checks, next_steps # noqa: E402 + +A = {a["case"]: a for a in ans.load_answers()} + + +def _ld(a): + m = re.search(r'', ans.jsonld(a), re.S) + return json.loads(m.group(1)) + + +def test_takeaway_never_leaves_only_dont_know(): + for a in A.values(): + t = ans.takeaway(a) + if a["verdict"] == "not_identified" or a.get("execution_kind") == "descriptive_only": + assert t and t["text"], a["case"] + hy = ans.takeaway(A["hyun2-land-permit-spillover-2020"]) + assert hy["head"] == "그래도 말할 수 있는 것" and "맞지 않습니다" in hy["text"] + + +def test_usage_rules_shared_with_page(): + a = A["hyun2-land-permit-spillover-2020"] + do, dont = ans.usage_rules(a) + page = ans.page_body(escape, a, {}, {}) + assert all(escape(x) in page for x in do + dont) + assert 'class="takeaway"' in page + + +def test_primary_range_in_percent_for_log_outcomes(): + pr = ans.primary_range(A["hyun2-land-permit-spillover-2020"]) + assert pr["unit"] == "%" and pr["lo"] < pr["est"] < pr["hi"] + + +def test_dataset_jsonld_and_no_claimreview_without_human_claims(): + a = A["hyun2-land-permit-spillover-2020"] + d = _ld({**a, "claims": []}) + assert d["@type"] == "Dataset" and d["distribution"][0]["contentUrl"].endswith(".csv") + + +def test_claimreview_only_with_valid_rating(): + a = A["hyun2-land-permit-spillover-2020"] + claim = { + "text": "토허제로 옆 동네 집값이 20% 올랐다", + "by": "어느 신문", + "url": "https://example.org/n", + "date": "2020-08-01", + } + d = _ld({**a, "claims": [claim | {"rating": "결과와 다름"}]}) + assert [x["@type"] for x in d] == ["Dataset", "ClaimReview"] + assert ( + d[1]["reviewRating"]["alternateName"] == "결과와 다름" + and d[1]["claimReviewed"] == claim["text"] + ) + d2 = _ld({**a, "claims": [claim | {"rating": "아마도"}]}) + assert d2["@type"] == "Dataset" + + +def test_review_status_shows_in_trust_and_todo(): + a = dict(A["hyun2-land-permit-spillover-2020"]) + assert any(h.startswith("검토 · 아직") for _, h, _ in checks(a | {"reviewed_by": []})) + assert any(h == "검토 · 통과" for _, h, _ in checks(a | {"reviewed_by": ["someone"]})) + p = {"stages": [True, True, True, True]} + assert any("검토 요청" in t for t in next_steps(p, a | {"reviewed_by": []}, True)) + card = ans.card(escape, a | {"reviewed_by": ["someone"]}, {}) + assert "검토됨" in card + + +def test_search_index_carries_claim_check_fields(tmp_path): + import projects as proj + import search + + from core.discovery.catalog import load_topics + from core.discovery.links import all_lineages + from core.discovery.ontology import load_datasets, load_issues + + items = search.index( + load_topics(), + load_issues(), + load_datasets(), + list(A.values()), + proj.load_projects(), + all_lineages(), + ) + res = [i for i in items if i["t"] == "result"] + assert all({"v", "ro", "pr", "rules", "rev"} <= i.keys() for i in res) + js = (ROOT / "site" / "search.js").read_text(encoding="utf-8") + assert "checkClaim" in js and "결과와 다름" in js and "공식 팩트체크가 아니에요" in js