feat: replace 39 infringement cases with v3.0 18-item manuscript checklist

- data/taxonomy/cases_v3.0.json: 아카이빙DB v3.0 「2.원고점검체계18」 + 부록1-A 대표판례.
  항목↔태그 매핑은 원문 표가 없어 tag_basis(명시/추정)로 구분 (추정 7항목은 컴북스 확인 대기)
- 분류 후보를 엔진 판별 대상(M1·M2·M7·M10·P2)으로 한정
- admin detect 응답 case_candidates 에 matched_tags·reason·decision_steps·author_request 추가
  (author 응답에서는 기존대로 제외)
- /v1/taxonomy 에 항목별 판단 기준·판정 단계·문면·태그 근거 노출

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
HyeongBaeYangandClaude Opus 5.5 committed 2026-10-20 10:07:41 +09:00
1 parent 7d985b4ec3
commit 12bb82a015
10 files changed
+757 -1006

No files matched your search

+30 -6
View File
@@ -53,7 +53,7 @@ from app.engine.similarity import (
build_text_backend,
)
from app.engine.structural import extract_lemmas
from app.engine.taxonomy import Taxonomy, load_taxonomy
from app.engine.taxonomy import CaseDef, Taxonomy, load_taxonomy
logger = logging.getLogger(__name__)
@@ -607,8 +607,8 @@ class PlagiarismDetector:
) -> MatchResult:
legacy_type = _classify_legacy(hit)
tags = self._assign_tags(hit, legacy_type)
cases = (self.taxonomy.find_cases([t.tag for t in tags if t.role == "primary"])
if self.taxonomy else ())
primary_tags = [t.tag for t in tags if t.role == "primary"]
cases = self.taxonomy.find_cases(primary_tags) if self.taxonomy else ()
candidates = [
CaseCandidate(
case_id=c.case_id,
@@ -620,6 +620,10 @@ class PlagiarismDetector:
p.case_id for p in c.representative_precedents if not p.in_runtime_corpus
],
precedent_note=c.representative_precedent_note,
matched_tags=[t for t in primary_tags if t in c.primary_tags],
reason=self._case_reason(c, primary_tags, hit, cases),
decision_steps=c.decision_steps,
author_request=c.author_request,
)
for c in cases
]
@@ -647,6 +651,26 @@ class PlagiarismDetector:
partial_signal=partial,
)
@staticmethod
def _case_reason(case: CaseDef, primary_tags: list[str], hit: SimilarityHit,
tie: tuple[CaseDef, ...]) -> str:
"""관리자 콘솔에 표시할 분류 사유. 엔진 신호 → 겹친 태그 → 항목 판단 기준 순."""
matched = "·".join(TAG_LABEL_KO[t] for t in primary_tags if t in case.primary_tags)
signal = (f"text={hit.text_sim:.2f} / lemma={hit.lemma_sim:.2f} / "
f"char={hit.element_sim.get('characters', 0.0):.2f} / "
f"motif={hit.element_sim.get('motifs', 0.0):.2f}")
reason = (f"엔진 주 태그 {matched}이(가) {case.case_id}({case.title})의 태그와 "
f"일치합니다 [{signal}].")
if len(tie) > 1:
ids = ", ".join(c.case_id for c in tie)
reason += (f" 텍스트만으로는 {ids} 중 하나로 좁혀지지 않으므로 작성자 관계"
"(대필·동일인·이중 등록)와 원본 종류를 확인해 확정해야 합니다.")
if case.check_point:
reason += f" 판단할 것: {case.check_point}"
if case.tag_basis == "추정":
reason += " (이 항목의 태그 매핑은 추정치로, 컴북스 확인 전입니다.)"
return reason
def _assign_tags(self, hit: SimilarityHit, legacy: InfringementType) -> list[InfringementTag]:
"""삼중 유사도 분포 → 10종 법령 태그(주/보조) 매핑.
@@ -731,10 +755,10 @@ class PlagiarismDetector:
tag_summary = ", ".join(primary_labels) if primary_labels else "확인 필요"
if len(top.case_candidates) > 1:
ids = ", ".join(c.case_id for c in top.case_candidates)
case_part = (f" 추정 케이스 후보 {ids} — 태그만으로는 구별되지 않으므로 "
f"베껴온 원본의 종류를 확인해 확정해야 합니다.")
case_part = (f" 추정 분류 후보 {ids} — 태그만으로는 구별되지 않으므로 "
f"작성자 관계와 원본 종류를 확인해 확정해야 합니다.")
elif top.case_id:
case_part = f" 추정 케이스 {top.case_id} ({top.case_title})."
case_part = f" 추정 분류 {top.case_id} ({top.case_title})."
else:
case_part = ""
return (
+26 -19
View File
@@ -1,10 +1,11 @@
"""10종 메타 태그 분류체계 + 39개 침해 케이스 로더.
"""10종 메타 태그 분류체계 + 원고 점검 체계 18항목 로더.
IV장(메타태그)과 IX장 「침해 케이스 ↔ 메타태그 매핑 총괄표」를 그대로 JSON으로
메타 태그(1층)와 원고 점검 체계 18항목(2층, M1~M10·P1~P4·R1~R3)을 JSON으로
보관 (data/taxonomy/). 부팅 시 1회 로드.
케이스 데이터는 실무방안 v1.3 기준이며, 케이스별 **대표판례**와 처리 구분
(● 기술검출 근거 / ○ 약관·신고)을 함께 담는다.
항목 데이터는 아카이빙DB v3.0 「2.원고점검체계18」 기준이며, 항목별 **대표판례**와
판정 단계·저자 보완 요청 문면을 함께 담는다. 항목↔태그 매핑은 원문에 표가 없어
문서 근거(tag_basis=명시)와 초안(tag_basis=추정)을 구분해 둔다.
"""
from __future__ import annotations
@@ -38,7 +39,7 @@ class RepresentativePrecedent:
@dataclass(frozen=True)
class CaseDef:
case_id: str # A1, A7, B1, ...
case_id: str # M1, M3a, P2, R1, ...
old_no: int
subgroup: str
title: str
@@ -48,12 +49,17 @@ class CaseDef:
detectable_internal: bool = False
high_risk: bool = False
note: str | None = None
#: v1.3 총괄표의 처리 구분. technical_detection(●) / terms_or_report(○)
#: 처리 구분. technical_detection(엔진 판별 대상) / terms_or_report(사람 확인)
handling: str = "terms_or_report"
representative_precedents: tuple[RepresentativePrecedent, ...] = field(default_factory=tuple)
#: 대표판례가 지정되지 않은 이유("확립 판례 없음" 등). 빈 목록과 구분한다.
representative_precedent_note: str | None = None
publication_verdict: str | None = None
check_point: str | None = None # 판단할 것
decision_steps: str | None = None # 판정 단계
author_request: str | None = None # 저자 보완 요청 문면 (P·R 층은 없음)
tag_basis: str | None = None # 명시 / 추정
tag_basis_note: str | None = None
@dataclass(frozen=True)
@@ -70,16 +76,15 @@ class Taxonomy:
return tag_id
def find_cases(self, primary_tags: Iterable[str]) -> tuple[CaseDef, ...]:
"""주 태그 조합에 가장 잘 맞는 케이스 **전부**를 반환한다.
"""주 태그 조합에 가장 잘 맞는 엔진 판별 대상 항목 **전부**를 반환한다.
태그만으로는 케이스가 1:1로 좁혀지지 않는다. A1·A2·A3·A4·A5·A6·A15 는
주/보조 태그가 완전히 같고, 실제 구별자는 베껴온 **원본의 종류**(가사·기사·
위키·교재·타인 자서전)다. 원본 종류 라벨은 코퍼스에 아직 없으므로, 동점
케이스 중 하나를 임의로 고르는 대신 동점군을 그대로 돌려준다. 호출자는
이를 "이 중 하나"로 제시하고 사람이 원본 종류로 확정한다.
후보는 detectable_internal 항목(M1·M2·M7·M10·P2)으로 한정한다. 이미지·음원·
계약·출간 후 보호 항목은 텍스트 유사도로 잡히지 않고, 섞으면 R1(내 책을 남이
베낌)처럼 원고 검사와 관점이 다른 항목이 M2보다 높게 나온다.
# ponytail: 원본 종류 라벨이 코퍼스에 들어오면 이 함수에 source_type 인자를
# 추가해 동점군을 좁힌다. 라벨 없는 상태에서 미리 배선하면 항상 None 이다.
태그만으로는 항목이 1:1로 좁혀지지 않는다. M7·M10·P2 는 작성자 관계(대필·
동일인·이중 등록)로 갈리는데 엔진은 텍스트만 보므로, 동점군을 그대로 돌려주고
사람이 확정한다.
"""
target = set(primary_tags)
if not target:
@@ -87,12 +92,9 @@ class Taxonomy:
scored: list[tuple[float, CaseDef]] = []
for c in self.cases:
primary = set(c.primary_tags)
if not primary:
if not primary or not c.detectable_internal:
continue
score = len(target & primary) / len(target | primary)
# v1.3 에서 기술검출 근거(●)로 확인된 케이스에 작은 가중치.
if c.detectable_internal:
score += 0.1
scored.append((score, c))
if not scored:
return ()
@@ -104,7 +106,7 @@ class Taxonomy:
def load_taxonomy(taxonomy_dir: Path) -> Taxonomy | None:
mt_path = taxonomy_dir / "meta_tags_v1.0.json"
cs_path = taxonomy_dir / "cases_v1.3.json"
cs_path = taxonomy_dir / "cases_v3.0.json"
if not mt_path.exists() or not cs_path.exists():
logger.warning("Taxonomy files not found in %s", taxonomy_dir)
return None
@@ -138,6 +140,11 @@ def load_taxonomy(taxonomy_dir: Path) -> Taxonomy | None:
),
representative_precedent_note=c.get("representative_precedent_note"),
publication_verdict=c.get("publication_verdict"),
check_point=c.get("check_point"),
decision_steps=c.get("decision_steps"),
author_request=c.get("author_request"),
tag_basis=c.get("tag_basis"),
tag_basis_note=c.get("tag_basis_note"),
)
for c in cs_data["cases"]
)