o2o-plagiarism-ai/scripts/show_summary_samples.py
hbyang 8aac18c255 chore: remove remaining project docs
docs 에 남아 있던 8개를 삭제한다. 내용은 git 이력(bbdda66)에 그대로 있으므로
필요하면 `git show bbdda66:docs/<파일>` 로 꺼낸다.

삭제: TEST_PLAN_2026_PHASE2, PERF_EVIDENCE_CAPTURE_2026, PRECISION_TEST_
PROCEDURE, SCOPE_AND_METRICS, CASE_MATCHING_KPI, IMPLEMENTATION_RUNBOOK,
PRECEDENT_LISTUP, COMBOOKS_CASE_MATCHING_REPLY_20260918.

삭제본을 출처로 가리키던 주석 4곳을 함께 정리했다(legal_risk.py,
build_precedent_listup_xlsx.py 2곳, show_summary_samples.py). 동작에는 영향이
없고 판례 표의 실제 원본은 data/precedents/precedent_listup.csv 와 해당
스크립트의 상수다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-28 10:04:10 +09:00

96 lines
3.5 KiB
Python

"""성능지표 #7 요약 정답셋 예시를 성적서 형식으로 출력한다.
전 차수 성적서(GERI `GERIR.CE.2511-02.009`) 3.2.3.3 "1. 데이터 준비" 는
원문을 `{index, original}` 형태로 앞뒤 몇 건만 싣고 중간을 `...` 로 생략한 뒤
총 건수를 적는다. 그 형식으로 낸다.
입력은 `scripts/eval_rouge.py` 와 같은 JSONL 이다.
{"text": "원문 ...", "reference": "사람 작성 요약 ..."}
{"text": "원문 ...", "references": ["정답 1 ...", "정답 2 ..."]}
`--with-reference` 를 주면 정답 요약도 함께 싣는다.
사용:
python scripts/show_summary_samples.py data/eval/summary.jsonl
python scripts/show_summary_samples.py data/eval/summary.jsonl --head 2 --tail 2
"""
from __future__ import annotations
import argparse
import json
from pathlib import Path
def record(index: int, row: dict, max_chars: int | None,
with_reference: bool) -> list[str]:
def clean(value: str) -> str:
body = " ".join(value.split())
if max_chars and len(body) > max_chars:
body = body[:max_chars] + " …"
return body
lines = [" {", ' "index": %d,' % index,
' "original": "%s",' % clean(row.get("text", ""))]
if with_reference:
raw = row.get("references") or row.get("reference", "")
references = [raw] if isinstance(raw, str) else list(raw)
if len(references) == 1:
lines.append(' "reference": "%s",' % clean(references[0]))
else:
lines.append(' "references": [')
for n, reference in enumerate(references):
comma = "," if n < len(references) - 1 else ""
lines.append(' "%s"%s' % (clean(reference), comma))
lines.append(" ],")
lines.append(" },")
return lines
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("dataset", type=Path, help="JSONL 정답셋")
parser.add_argument("--head", type=int, default=2, help="앞에서 N건")
parser.add_argument("--tail", type=int, default=2, help="뒤에서 N건")
parser.add_argument("--max-chars", type=int, default=None,
help="본문 길이 제한 (미지정 시 전문)")
parser.add_argument("--with-reference", action="store_true",
help="정답 요약도 함께 출력")
parser.add_argument("--out", help="파일로 저장")
args = parser.parse_args()
if not args.dataset.exists():
raise SystemExit(
"정답셋이 없습니다: %s\n"
"성능지표 #7 은 요약 정답셋 구축 후 측정 가능하다. "
"시험 계획 부록 E 참조." % args.dataset)
rows = [json.loads(line) for line
in args.dataset.read_text(encoding="utf-8").splitlines() if line.strip()]
total = len(rows)
indices = list(range(min(args.head, total)))
tail_start = max(len(indices), total - args.tail)
indices += list(range(tail_start, total))
lines = ["1. 데이터 준비"]
previous = -1
for i in indices:
if previous >= 0 and i != previous + 1:
lines.append("...")
lines.extend(record(i + 1, rows[i], args.max_chars, args.with_reference))
previous = i
lines.append("")
lines.append("총 데이터 %d건" % total)
text = "\n".join(lines)
if args.out:
Path(args.out).write_text(text + "\n", encoding="utf-8")
print("%s 에 기록" % args.out)
else:
print(text)
return 0
if __name__ == "__main__":
raise SystemExit(main())