Compare commits
5
Commits
03d500d67c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e639ba7eb | ||
|
|
c172981c6c | ||
|
|
aaf88d0c1d | ||
|
|
7094d80566 | ||
|
|
f0e657b6d4 |
No files matched your search
@@ -0,0 +1,67 @@
|
|||||||
|
# main push → 이미지 빌드(linux/amd64) → ECR plagiarism-api:<sha> → SSM Deploy-plagiarism → o2o-platform-plagiarism
|
||||||
|
# 서버의 /srv/plagiarism/deploy.sh가 교체 후 health를 보고, 실패하면 직전 이미지로 되돌린다.
|
||||||
|
# 인프라 정의: o2o-aws infra/envs/prod/plagiarism.tf (역할·문서·ECR), infra/server/plagiarism (서버 스크립트)
|
||||||
|
# 같은 sha 재배포·롤백: Actions에서 이 워크플로를 main에 수동 실행(이미지가 이미 있으면 빌드를 건너뛴다).
|
||||||
|
name: deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: deploy
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
AWS_REGION: ap-northeast-2
|
||||||
|
ROLE_ARN: arn:aws:iam::277206319065:role/o2o-github-deploy-plagiarism
|
||||||
|
ECR_REPO: plagiarism-api
|
||||||
|
INSTANCE_ID: i-03733fc4b9ce2a1e7
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
timeout-minutes: 40
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: aws-actions/configure-aws-credentials@v4
|
||||||
|
with:
|
||||||
|
role-to-assume: ${{ env.ROLE_ARN }}
|
||||||
|
aws-region: ${{ env.AWS_REGION }}
|
||||||
|
|
||||||
|
- id: ecr
|
||||||
|
uses: aws-actions/amazon-ecr-login@v2
|
||||||
|
|
||||||
|
- name: Build and push (skip if the tag exists)
|
||||||
|
env:
|
||||||
|
IMAGE: ${{ steps.ecr.outputs.registry }}/${{ env.ECR_REPO }}:${{ github.sha }}
|
||||||
|
run: |
|
||||||
|
if aws ecr describe-images --repository-name "$ECR_REPO" --image-ids imageTag="$GITHUB_SHA" >/dev/null 2>&1; then
|
||||||
|
echo "image exists, skip build: $IMAGE"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
docker build --platform linux/amd64 --target runtime -t "$IMAGE" .
|
||||||
|
docker push "$IMAGE"
|
||||||
|
|
||||||
|
- name: Deploy via SSM
|
||||||
|
run: |
|
||||||
|
cid=$(aws ssm send-command --instance-ids "$INSTANCE_ID" --document-name Deploy-plagiarism \
|
||||||
|
--parameters Tag="$GITHUB_SHA" --query Command.CommandId --output text)
|
||||||
|
echo "command $cid"
|
||||||
|
for _ in $(seq 1 120); do
|
||||||
|
sleep 10
|
||||||
|
status=$(aws ssm get-command-invocation --command-id "$cid" --instance-id "$INSTANCE_ID" \
|
||||||
|
--query Status --output text 2>/dev/null || echo Pending)
|
||||||
|
case "$status" in Pending|InProgress|Delayed) continue ;; esac
|
||||||
|
break
|
||||||
|
done
|
||||||
|
aws ssm get-command-invocation --command-id "$cid" --instance-id "$INSTANCE_ID" \
|
||||||
|
--query '[StandardOutputContent,StandardErrorContent]' --output text
|
||||||
|
echo "status: $status"
|
||||||
|
[ "$status" = Success ]
|
||||||
+4
-3
@@ -1,4 +1,5 @@
|
|||||||
FROM python:3.13-slim AS base
|
# 3.13.2: King 서버 운영 이미지와 같은 Python (constraints.txt와 함께 joblib 모델 호환 유지)
|
||||||
|
FROM python:3.13.2-slim AS base
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -14,8 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
build-essential \
|
build-essential \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY requirements.txt .
|
COPY requirements.txt constraints.txt ./
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt -c constraints.txt
|
||||||
|
|
||||||
COPY app ./app
|
COPY app ./app
|
||||||
COPY data ./data
|
COPY data ./data
|
||||||
|
|||||||
@@ -132,6 +132,10 @@ async def copyright_review(
|
|||||||
}
|
}
|
||||||
if legal.llm_verdict == "likely":
|
if legal.llm_verdict == "likely":
|
||||||
legal_status, legal_label = "suspected", "판례에 비추어 저작권 침해 의심"
|
legal_status, legal_label = "suspected", "판례에 비추어 저작권 침해 의심"
|
||||||
|
# TODO: 일치가 없는 의심 낮음(no_registered_corpus_match)은 엔진이 판례·요약을 비워 보낸다.
|
||||||
|
# LLM 판단(USE_LLM_LEGAL_JUDGE)이 unlikely 인 경우는 일치가 있는 글이라 판례·요약이 그대로
|
||||||
|
# 남는다. 바이칼 요청("의심 낮음이면 판례·요약 미반환")과 어긋나므로 LLM 판단을 운영에서
|
||||||
|
# 켜기 전에 이 경우도 precedent_ids=[]·summary="" 로 맞춰야 한다.
|
||||||
elif (
|
elif (
|
||||||
legal.llm_verdict == "unlikely"
|
legal.llm_verdict == "unlikely"
|
||||||
or legal.status == "no_registered_corpus_match"
|
or legal.status == "no_registered_corpus_match"
|
||||||
|
|||||||
+51
-6
@@ -57,6 +57,11 @@ from app.engine.taxonomy import CaseDef, Taxonomy, load_taxonomy
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
#: 원고 점검 항목을 정하지 못한 매칭에 붙이는 예외 코드. 분류 체계의 항목이
|
||||||
|
#: 아니므로 /v1/taxonomy 에는 없고, 정하지 못한 이유는 후보의 reason 에 남긴다.
|
||||||
|
UNCLASSIFIED_CASE_ID = "F1"
|
||||||
|
UNCLASSIFIED_CASE_TITLE = "미분류"
|
||||||
|
|
||||||
|
|
||||||
class PlagiarismDetector:
|
class PlagiarismDetector:
|
||||||
#: 참조 특징 프로세스 캐시 상한. 초과하면 통째로 비운다(단순 LRU 대용).
|
#: 참조 특징 프로세스 캐시 상한. 초과하면 통째로 비운다(단순 LRU 대용).
|
||||||
@@ -629,14 +634,16 @@ class PlagiarismDetector:
|
|||||||
)
|
)
|
||||||
for c in cases
|
for c in cases
|
||||||
]
|
]
|
||||||
|
if not candidates:
|
||||||
|
candidates = [self._unclassified_candidate(self.taxonomy, primary_tags, hit)]
|
||||||
|
|
||||||
return MatchResult(
|
return MatchResult(
|
||||||
source_doc=hit.doc_id,
|
source_doc=hit.doc_id,
|
||||||
source_title=hit.title,
|
source_title=hit.title,
|
||||||
similarity=round(hit.score, 4),
|
similarity=round(hit.score, 4),
|
||||||
tags=tags,
|
tags=tags,
|
||||||
case_id=cases[0].case_id if cases else None,
|
case_id=candidates[0].case_id,
|
||||||
case_title=cases[0].title if cases else None,
|
case_title=candidates[0].title,
|
||||||
case_candidates=candidates,
|
case_candidates=candidates,
|
||||||
publication_verdict_status=("review_required" if any(
|
publication_verdict_status=("review_required" if any(
|
||||||
c.publication_verdict is not None for c in candidates
|
c.publication_verdict is not None for c in candidates
|
||||||
@@ -658,11 +665,8 @@ class PlagiarismDetector:
|
|||||||
tie: tuple[CaseDef, ...]) -> str:
|
tie: tuple[CaseDef, ...]) -> str:
|
||||||
"""관리자 콘솔에 표시할 분류 사유. 엔진 신호 → 겹친 태그 → 항목 판단 기준 순."""
|
"""관리자 콘솔에 표시할 분류 사유. 엔진 신호 → 겹친 태그 → 항목 판단 기준 순."""
|
||||||
matched = "·".join(TAG_LABEL_KO[t] for t in primary_tags if t in case.primary_tags)
|
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})의 태그와 "
|
reason = (f"엔진 주 태그 {matched}이(가) {case.case_id}({case.title})의 태그와 "
|
||||||
f"일치합니다 [{signal}].")
|
f"일치합니다 [{_score_signal(hit)}].")
|
||||||
if len(tie) > 1:
|
if len(tie) > 1:
|
||||||
ids = ", ".join(c.case_id for c in tie)
|
ids = ", ".join(c.case_id for c in tie)
|
||||||
reason += (f" 텍스트만으로는 {ids} 중 하나로 좁혀지지 않으므로 작성자 관계"
|
reason += (f" 텍스트만으로는 {ids} 중 하나로 좁혀지지 않으므로 작성자 관계"
|
||||||
@@ -673,6 +677,37 @@ class PlagiarismDetector:
|
|||||||
reason += " (이 항목의 태그 매핑은 추정치로, 컴북스 확인 전입니다.)"
|
reason += " (이 항목의 태그 매핑은 추정치로, 컴북스 확인 전입니다.)"
|
||||||
return reason
|
return reason
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _unclassified_candidate(taxonomy: Taxonomy | None, primary_tags: list[str],
|
||||||
|
hit: SimilarityHit) -> CaseCandidate:
|
||||||
|
"""항목을 정하지 못한 매칭의 F1 후보. 사유는 정하지 못한 지점마다 다르다.
|
||||||
|
|
||||||
|
- 분류 체계 미로드 → 설정 확인 필요
|
||||||
|
- 주 태그 없음(_assign_tags 의 마지막 분기) → 사람이 항목 지정
|
||||||
|
- 주 태그는 있으나 판별 대상 항목과 겹치지 않음 → 사람이 항목 지정
|
||||||
|
"""
|
||||||
|
signal = _score_signal(hit)
|
||||||
|
if taxonomy is None:
|
||||||
|
reason = (f"분류 체계를 불러오지 못해 원고 점검 항목을 매기지 못했습니다 "
|
||||||
|
f"[{signal}]. 서버의 TAXONOMY_DIR 설정을 확인해야 합니다.")
|
||||||
|
elif not primary_tags:
|
||||||
|
reason = (f"엔진이 주 태그를 내지 못해 원고 점검 항목 중 대응되는 항목이 "
|
||||||
|
f"없습니다 [{signal}]. 일치 구간과 원본 종류를 확인해 항목을 "
|
||||||
|
"사람이 지정해야 합니다.")
|
||||||
|
else:
|
||||||
|
matched = "·".join(TAG_LABEL_KO[t] for t in primary_tags)
|
||||||
|
targets = "·".join(c.case_id for c in taxonomy.cases if c.detectable_internal)
|
||||||
|
reason = (f"엔진 주 태그 {matched}이(가) 엔진 판별 대상 항목({targets})과 "
|
||||||
|
f"충분히 겹치지 않습니다 [{signal}]. 일치 구간과 원본 종류를 확인해 "
|
||||||
|
"항목을 사람이 지정해야 합니다.")
|
||||||
|
return CaseCandidate(
|
||||||
|
case_id=UNCLASSIFIED_CASE_ID,
|
||||||
|
title=UNCLASSIFIED_CASE_TITLE,
|
||||||
|
handling="terms_or_report",
|
||||||
|
precedent_note="분류 미확정이라 대표판례를 지정하지 않습니다.",
|
||||||
|
reason=reason,
|
||||||
|
)
|
||||||
|
|
||||||
def _assign_tags(self, hit: SimilarityHit, legacy: InfringementType,
|
def _assign_tags(self, hit: SimilarityHit, legacy: InfringementType,
|
||||||
exact_span: bool = False) -> list[InfringementTag]:
|
exact_span: bool = False) -> list[InfringementTag]:
|
||||||
"""삼중 유사도 분포 → 10종 법령 태그(주/보조) 매핑.
|
"""삼중 유사도 분포 → 10종 법령 태그(주/보조) 매핑.
|
||||||
@@ -768,6 +803,9 @@ class PlagiarismDetector:
|
|||||||
ids = ", ".join(c.case_id for c in top.case_candidates)
|
ids = ", ".join(c.case_id for c in top.case_candidates)
|
||||||
case_part = (f" 추정 분류 후보 {ids} — 태그만으로는 구별되지 않으므로 "
|
case_part = (f" 추정 분류 후보 {ids} — 태그만으로는 구별되지 않으므로 "
|
||||||
f"작성자 관계와 원본 종류를 확인해 확정해야 합니다.")
|
f"작성자 관계와 원본 종류를 확인해 확정해야 합니다.")
|
||||||
|
elif top.case_id == UNCLASSIFIED_CASE_ID:
|
||||||
|
case_part = (f" 분류 미확정({UNCLASSIFIED_CASE_ID}) — 원본 종류와 일치 구간을 "
|
||||||
|
"확인해 항목을 지정해야 합니다.")
|
||||||
elif top.case_id:
|
elif top.case_id:
|
||||||
case_part = f" 추정 분류 {top.case_id} ({top.case_title})."
|
case_part = f" 추정 분류 {top.case_id} ({top.case_title})."
|
||||||
else:
|
else:
|
||||||
@@ -796,6 +834,13 @@ def _calibrate_similarity(raw: float, threshold: float) -> int:
|
|||||||
return max(0, min(100, round(disp)))
|
return max(0, min(100, round(disp)))
|
||||||
|
|
||||||
|
|
||||||
|
def _score_signal(hit: SimilarityHit) -> str:
|
||||||
|
"""분류 사유에 붙이는 유사도 성분 요약."""
|
||||||
|
return (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}")
|
||||||
|
|
||||||
|
|
||||||
def _classify_legacy(hit: SimilarityHit) -> InfringementType:
|
def _classify_legacy(hit: SimilarityHit) -> InfringementType:
|
||||||
"""후방 호환 - 단일 enum 분류 (UI/기존 통합 코드용)."""
|
"""후방 호환 - 단일 enum 분류 (UI/기존 통합 코드용)."""
|
||||||
elem = hit.element_sim
|
elem = hit.element_sim
|
||||||
|
|||||||
@@ -241,10 +241,15 @@ class LegalRiskEngine:
|
|||||||
if not rights_verified:
|
if not rights_verified:
|
||||||
missing.append("저작권 귀속·이용허락·인용 요건")
|
missing.append("저작권 귀속·이용허락·인용 요건")
|
||||||
|
|
||||||
|
# 탐지 일치(matches)가 없으면 호출부가 max_similarity=0 을 넘긴다. coverage 는
|
||||||
|
# 일치 판정 전 후보와의 12자 이상 공통 구간이라 흔한 표현만으로도 0을 넘으므로
|
||||||
|
# 등급 기준에 쓰지 않는다. 일치가 없으면 판례·요약도 붙이지 않는다.
|
||||||
|
no_match = max_similarity <= 0
|
||||||
if not self.precedents:
|
if not self.precedents:
|
||||||
status, level = "insufficient_precedent_data", None
|
status, level = "insufficient_precedent_data", None
|
||||||
elif max_similarity <= 0 and coverage <= 0:
|
elif no_match:
|
||||||
status, level = "no_registered_corpus_match", "low"
|
status, level = "no_registered_corpus_match", "low"
|
||||||
|
related = []
|
||||||
else:
|
else:
|
||||||
status = "review_required"
|
status = "review_required"
|
||||||
strong_copy = coverage >= 0.30 or longest_span >= 100
|
strong_copy = coverage >= 0.30 or longest_span >= 100
|
||||||
@@ -269,7 +274,7 @@ class LegalRiskEngine:
|
|||||||
precedent_grades=tuple((p.case_id, p.grade) for p in related if p.grade),
|
precedent_grades=tuple((p.case_id, p.grade) for p in related if p.grade),
|
||||||
judgment_summary=_rule_based_summary(status, related),
|
judgment_summary=_rule_based_summary(status, related),
|
||||||
)
|
)
|
||||||
if self.judge is None or not related or (max_similarity <= 0 and coverage <= 0):
|
if self.judge is None or not related or no_match:
|
||||||
return base
|
return base
|
||||||
|
|
||||||
request = LegalJudgeInput(
|
request = LegalJudgeInput(
|
||||||
@@ -333,10 +338,7 @@ def _rule_based_summary(status: str, related: list[Precedent]) -> str:
|
|||||||
if status == "insufficient_precedent_data":
|
if status == "insufficient_precedent_data":
|
||||||
return "등록된 판례가 없어 판례에 따른 검토 의견을 제시할 수 없습니다."
|
return "등록된 판례가 없어 판례에 따른 검토 의견을 제시할 수 없습니다."
|
||||||
if status == "no_registered_corpus_match":
|
if status == "no_registered_corpus_match":
|
||||||
return (
|
return ""
|
||||||
"등록 코퍼스에서 일치 증거가 확인되지 않아 판례 기반 침해 의심을 제시하지 않습니다. "
|
|
||||||
"다만 미매칭은 비침해 확정이 아닙니다."
|
|
||||||
)
|
|
||||||
ids = ", ".join(p.case_id for p in related[:3])
|
ids = ", ".join(p.case_id for p in related[:3])
|
||||||
suffix = f" 등 {len(related)}건" if len(related) > 3 else ""
|
suffix = f" 등 {len(related)}건" if len(related) > 3 else ""
|
||||||
return f"{ids}{suffix} 판례가 관련 판례로 검색되어 구체적인 사실관계 검토가 필요합니다."
|
return f"{ids}{suffix} 판례가 관련 판례로 검색되어 구체적인 사실관계 검토가 필요합니다."
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# King 서버 운영 이미지(2026-10-21 빌드, 커밋 03d500d)의 pip freeze. joblib 모델(scikit-learn) 호환을 위해 이 버전으로 고정한다.
|
||||||
|
# 버전을 올릴 때는 AI 의심도 모델을 같은 버전으로 다시 저장하고 킹/AWS 점수 비교를 다시 한다.
|
||||||
|
annotated-doc==0.0.5
|
||||||
|
annotated-types==0.8.0
|
||||||
|
anyio==4.14.2
|
||||||
|
certifi==2026.7.22
|
||||||
|
click==8.4.2
|
||||||
|
datasketch==2.0.0
|
||||||
|
et_xmlfile==2.0.0
|
||||||
|
fastapi==0.141.1
|
||||||
|
h11==0.16.0
|
||||||
|
httpcore==1.0.9
|
||||||
|
httpcore2==2.12.0
|
||||||
|
httptools==0.8.0
|
||||||
|
httpx==0.28.1
|
||||||
|
httpx2==2.12.0
|
||||||
|
idna==3.19
|
||||||
|
jiter==0.16.0
|
||||||
|
joblib==1.5.3
|
||||||
|
kiwipiepy==0.23.2
|
||||||
|
kiwipiepy_model==0.23.0
|
||||||
|
lxml==6.1.2
|
||||||
|
narwhals==2.24.0
|
||||||
|
numpy==2.5.2
|
||||||
|
openai==3.3.1
|
||||||
|
openpyxl==3.1.5
|
||||||
|
pydantic==2.13.4
|
||||||
|
pydantic-settings==2.15.0
|
||||||
|
pydantic_core==2.46.4
|
||||||
|
pypdf==6.16.1
|
||||||
|
python-docx==1.2.0
|
||||||
|
python-dotenv==1.2.3
|
||||||
|
python-multipart==0.0.32
|
||||||
|
PyYAML==6.0.3
|
||||||
|
scikit-learn==1.9.0
|
||||||
|
scipy==1.18.0
|
||||||
|
sniffio==1.3.1
|
||||||
|
starlette==1.6.0
|
||||||
|
threadpoolctl==3.6.0
|
||||||
|
tqdm==4.70.0
|
||||||
|
truststore==0.10.4
|
||||||
|
typing-inspection==0.4.4
|
||||||
|
typing_extensions==4.16.0
|
||||||
|
uvicorn==0.52.4
|
||||||
|
uvloop==0.22.1
|
||||||
|
watchfiles==1.2.0
|
||||||
|
websockets==17.0.1
|
||||||
+20
-2
@@ -57,6 +57,9 @@ curl -X POST https://plagiarism.o2o.kr/v1/plagiarism/detect \
|
|||||||
> `ai_generation_suspicion.level` 값은 `low`, `medium`, `high`, `unknown`이며,
|
> `ai_generation_suspicion.level` 값은 `low`, `medium`, `high`, `unknown`이며,
|
||||||
> 화면은 함께 반환되는 한글 `label`을 그대로 표시한다.
|
> 화면은 함께 반환되는 한글 `label`을 그대로 표시한다.
|
||||||
|
|
||||||
|
> 일치 구간이 없으면 `legal_judgment.status`는 `low`(침해 의심 낮음)이며,
|
||||||
|
> 이때 `legal_judgment.precedent_ids`는 `[]`, `legal_judgment.summary`는 `""`로 반환한다.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 2. 저작권 탭 경량 검사 — `POST /v1/plagiarism/review`
|
## 2. 저작권 탭 경량 검사 — `POST /v1/plagiarism/review`
|
||||||
@@ -210,8 +213,8 @@ curl -X POST https://plagiarism.o2o.kr/v1/plagiarism/detect \
|
|||||||
| `ai_generation` | object | AI 생성 의심도 상세. 현재 학습 모델 사용 시 `available=true`, `is_stub=false` |
|
| `ai_generation` | object | AI 생성 의심도 상세. 현재 학습 모델 사용 시 `available=true`, `is_stub=false` |
|
||||||
| `matches[]` | array | 매칭된 원본별 상세 (표절 시). 태그·분류·근거 구간 포함 |
|
| `matches[]` | array | 매칭된 원본별 상세 (표절 시). 태그·분류·근거 구간 포함 |
|
||||||
| `matches[].tags[]` | array | 법령 태그. `role`: `primary`(주)/`secondary`(보조), `label_ko` 한글 표기 |
|
| `matches[].tags[]` | array | 법령 태그. `role`: `primary`(주)/`secondary`(보조), `label_ko` 한글 표기 |
|
||||||
| `matches[].case_id` | string\|null | 원고 점검 18항목 분류 코드(예: `M1`). `case_candidates[0]` 과 같다. 분류되지 않으면 null (§8) |
|
| `matches[].case_id` | string | 원고 점검 18항목 분류 코드(예: `M1`). `case_candidates[0]` 과 같다. 항목을 정하지 못하면 예외 코드 `F1` (§8-4) |
|
||||||
| `matches[].case_title` | string\|null | 분류명 (예: `남의 글을 옮겨 실었다`) |
|
| `matches[].case_title` | string | 분류명 (예: `남의 글을 옮겨 실었다`). `F1`이면 `미분류` |
|
||||||
| `matches[].case_candidates[]` | array | 태그 동점 분류 **전부**. 2개 이상이면 텍스트만으로 하나로 좁혀지지 않으므로 "이 중 하나"로 표시하고 사람이 확정한다 |
|
| `matches[].case_candidates[]` | array | 태그 동점 분류 **전부**. 2개 이상이면 텍스트만으로 하나로 좁혀지지 않으므로 "이 중 하나"로 표시하고 사람이 확정한다 |
|
||||||
| `matches[].case_candidates[].handling` | string | `technical_detection`(엔진 판별 대상) / `terms_or_report`(사람 확인 대상) |
|
| `matches[].case_candidates[].handling` | string | `technical_detection`(엔진 판별 대상) / `terms_or_report`(사람 확인 대상) |
|
||||||
| `matches[].case_candidates[].publication_verdict` | string | 항목의 기본 출간 판정 (예: `조건부`). 이 원고의 최종 판정이 아니다 (§7-2) |
|
| `matches[].case_candidates[].publication_verdict` | string | 항목의 기본 출간 판정 (예: `조건부`). 이 원고의 최종 판정이 아니다 (§7-2) |
|
||||||
@@ -391,3 +394,18 @@ taxonomy 항목과 관리자용 case_candidates 각각에 `publication_verdict`
|
|||||||
- 나머지 13항목(이미지·음원·편지·계약 등)은 텍스트로 판별하지 않으며 사람이 확인한다.
|
- 나머지 13항목(이미지·음원·편지·계약 등)은 텍스트로 판별하지 않으며 사람이 확인한다.
|
||||||
- 항목↔태그 매핑 중 7항목(M3a·M3b·M4·M5·M6·M10·R1)은 컴북스 확인 전이다
|
- 항목↔태그 매핑 중 7항목(M3a·M3b·M4·M5·M6·M10·R1)은 컴북스 확인 전이다
|
||||||
(`/v1/taxonomy`의 `tag_basis=추정`). 확인 후 값이 바뀌어도 응답 형식은 그대로다.
|
(`/v1/taxonomy`의 `tag_basis=추정`). 확인 후 값이 바뀌어도 응답 형식은 그대로다.
|
||||||
|
|
||||||
|
### 8-4. 예외 코드 F1 (미분류)
|
||||||
|
|
||||||
|
매칭은 있지만 18항목 중 어느 항목도 정하지 못하면 `case_id`를 null 대신 `F1`로 낸다.
|
||||||
|
`F1`은 18항목이 아닌 예외 코드라 `GET /v1/taxonomy`에는 없다. `case_candidates`에는
|
||||||
|
`F1` 후보 하나(`title=미분류`, `handling=terms_or_report`)가 들어가고, 정하지 못한 이유는
|
||||||
|
그 후보의 `reason`에 담긴다.
|
||||||
|
|
||||||
|
| 경우 | `reason` 요지 |
|
||||||
|
|---|---|
|
||||||
|
| 엔진이 주 태그를 내지 못함 | 일치 구간과 원본 종류를 확인해 사람이 항목 지정 |
|
||||||
|
| 주 태그가 엔진 판별 대상 항목과 충분히 겹치지 않음 | 일치 구간과 원본 종류를 확인해 사람이 항목 지정 |
|
||||||
|
| 서버가 분류 체계를 불러오지 못함 | 서버 설정(`TAXONOMY_DIR`) 확인 필요 |
|
||||||
|
|
||||||
|
매칭이 없는 응답(`matches=[]`)에는 분류 코드가 없다.
|
||||||
@@ -65,6 +65,20 @@ def test_copyright_review_returns_only_mobile_tab_fields():
|
|||||||
assert "score_semantics" not in body
|
assert "score_semantics" not in body
|
||||||
|
|
||||||
|
|
||||||
|
def test_copyright_review_low_omits_precedents_and_summary():
|
||||||
|
"""35자 미만 본문은 일치가 날 수 없으므로 의심 낮음이고 판례·요약이 비어야 한다."""
|
||||||
|
with TestClient(app) as client:
|
||||||
|
resp = client.post(
|
||||||
|
"/v1/plagiarism/review",
|
||||||
|
json={"doc_id": "mobile-low", "text": "창밖으로 보이는 숲은 오늘따라 푸르게 보였다."},
|
||||||
|
)
|
||||||
|
assert resp.status_code == 200
|
||||||
|
legal = resp.json()["legal_judgment"]
|
||||||
|
assert legal["status"] == "low"
|
||||||
|
assert legal["precedent_ids"] == []
|
||||||
|
assert legal["summary"] == ""
|
||||||
|
|
||||||
|
|
||||||
def test_batch_flow():
|
def test_batch_flow():
|
||||||
with TestClient(app) as client:
|
with TestClient(app) as client:
|
||||||
resp = client.post(
|
resp = client.post(
|
||||||
|
|||||||
@@ -136,6 +136,46 @@ def test_case_reason_explains_tags_ties_and_draft_mapping():
|
|||||||
assert '추정치' in PlagiarismDetector._case_reason(m10, ['reproduction'], hit, tie)
|
assert '추정치' in PlagiarismDetector._case_reason(m10, ['reproduction'], hit, tie)
|
||||||
|
|
||||||
|
|
||||||
|
def test_unclassified_reason_differs_by_route():
|
||||||
|
from app.engine.detector import PlagiarismDetector
|
||||||
|
from app.engine.similarity import SimilarityHit
|
||||||
|
tax = load_taxonomy(Path('data/taxonomy'))
|
||||||
|
hit = SimilarityHit(doc_id='d', title='t', score=.4, text_sim=.2, lemma_sim=.2,
|
||||||
|
element_sim={'characters': .1, 'motifs': .1}, evidence=[])
|
||||||
|
no_taxonomy = PlagiarismDetector._unclassified_candidate(None, ['reproduction'], hit)
|
||||||
|
no_primary = PlagiarismDetector._unclassified_candidate(tax, [], hit)
|
||||||
|
no_overlap = PlagiarismDetector._unclassified_candidate(tax, ['integrity'], hit)
|
||||||
|
assert tax.find_cases(['integrity']) == ()
|
||||||
|
for c in (no_taxonomy, no_primary, no_overlap):
|
||||||
|
assert c.case_id == 'F1' and c.title == '미분류'
|
||||||
|
assert c.handling == 'terms_or_report' and c.matched_tags == []
|
||||||
|
assert c.precedent_note and 'text=0.20' in c.reason
|
||||||
|
assert 'TAXONOMY_DIR' in no_taxonomy.reason
|
||||||
|
assert no_primary.reason.startswith('엔진이 주 태그를 내지 못해')
|
||||||
|
assert '동일성유지권' in no_overlap.reason and 'M1·M2·M7·M10·P2' in no_overlap.reason
|
||||||
|
assert len({no_taxonomy.reason, no_primary.reason, no_overlap.reason}) == 3
|
||||||
|
|
||||||
|
|
||||||
|
def test_match_without_primary_tags_gets_f1():
|
||||||
|
"""주 태그가 없어 항목을 못 정한 매칭도 case_id 가 null 이 아니라 F1 이어야 한다."""
|
||||||
|
from app.engine.detector import PlagiarismDetector
|
||||||
|
from app.engine.similarity import SimilarityHit
|
||||||
|
hit = SimilarityHit(doc_id='d', title='t', score=.4, text_sim=.2, lemma_sim=.2,
|
||||||
|
element_sim={'characters': .1, 'motifs': .1}, evidence=[])
|
||||||
|
det = PlagiarismDetector.__new__(PlagiarismDetector)
|
||||||
|
det.taxonomy = load_taxonomy(Path('data/taxonomy'))
|
||||||
|
match = det._to_match(hit, True, None)
|
||||||
|
assert [t.role for t in match.tags] == ['secondary']
|
||||||
|
assert match.case_id == 'F1' and match.case_title == '미분류'
|
||||||
|
assert [c.case_id for c in match.case_candidates] == ['F1']
|
||||||
|
assert match.case_candidates[0].reason.startswith('엔진이 주 태그를 내지 못해')
|
||||||
|
assert match.publication_verdict_status == 'source_pending'
|
||||||
|
assert '분류 미확정(F1)' in det._build_ccl_basis([match])
|
||||||
|
det.taxonomy = None
|
||||||
|
match = det._to_match(hit, True, None)
|
||||||
|
assert match.case_id == 'F1' and 'TAXONOMY_DIR' in match.case_candidates[0].reason
|
||||||
|
|
||||||
|
|
||||||
def test_partial_verbatim_copy_gets_case_code(tmp_path):
|
def test_partial_verbatim_copy_gets_case_code(tmp_path):
|
||||||
"""원고 일부만 그대로 옮긴 경우 전체 유사도가 중간이라도 분류 코드가 비면 안 된다.
|
"""원고 일부만 그대로 옮긴 경우 전체 유사도가 중간이라도 분류 코드가 비면 안 된다.
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,20 @@ def test_risk_requires_missing_facts_and_only_registered_case_ids():
|
|||||||
assert len(result.missing_factors) == 3
|
assert len(result.missing_factors) == 3
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_detect_match_is_low_without_precedents_or_summary():
|
||||||
|
"""일치(matches)가 없으면 12자 공통 표현으로 coverage 가 있어도 의심 낮음이다."""
|
||||||
|
judge = _FakeJudge()
|
||||||
|
result = LegalRiskEngine([_case()], judge=judge).assess(
|
||||||
|
max_similarity=0.0, coverage=0.2, longest_span=0, legal_tags=[],
|
||||||
|
)
|
||||||
|
assert result.status == "no_registered_corpus_match"
|
||||||
|
assert result.risk_level == "low"
|
||||||
|
assert result.precedent_ids == ()
|
||||||
|
assert result.precedent_grades == ()
|
||||||
|
assert result.judgment_summary == ""
|
||||||
|
assert judge.request is None
|
||||||
|
|
||||||
|
|
||||||
def test_repository_seed_is_valid():
|
def test_repository_seed_is_valid():
|
||||||
cases = load_precedents("data/precedents/precedents.jsonl")
|
cases = load_precedents("data/precedents/precedents.jsonl")
|
||||||
assert cases
|
assert cases
|
||||||
|
|||||||
Reference in new issue
Block a user