fix: assign case code to partial verbatim copies with exact-span evidence
원고 일부만 그대로 옮기면 전체 유사도가 중간이라 주 태그가 비어 case_id 가 null 로 내려갔다. 35자 이상 연속 일치로 채택된 매칭은 복제권·인용 누락을 주 태그로 붙여 M1 으로 분류한다. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2043b6d399
commit
03d500d67c
2 files changed
+44
-2
No files matched your search
+13
-2
@@ -316,6 +316,7 @@ class PlagiarismDetector:
|
||||
match = self._to_match(
|
||||
h, opts.return_evidence, lsh_jaccards.get(h.doc_id),
|
||||
self._partial_signal(h.doc_id, elements, query_lemmas),
|
||||
exact_span="exact_span" in reasons,
|
||||
)
|
||||
if provenance_hit:
|
||||
match = self._add_provenance(match, provenance_hit)
|
||||
@@ -604,9 +605,10 @@ class PlagiarismDetector:
|
||||
return_evidence: bool,
|
||||
lsh_j: float | None,
|
||||
partial: PartialPlagiarismSignal | None = None,
|
||||
exact_span: bool = False,
|
||||
) -> MatchResult:
|
||||
legacy_type = _classify_legacy(hit)
|
||||
tags = self._assign_tags(hit, legacy_type)
|
||||
tags = self._assign_tags(hit, legacy_type, exact_span)
|
||||
primary_tags = [t.tag for t in tags if t.role == "primary"]
|
||||
cases = self.taxonomy.find_cases(primary_tags) if self.taxonomy else ()
|
||||
candidates = [
|
||||
@@ -671,7 +673,8 @@ class PlagiarismDetector:
|
||||
reason += " (이 항목의 태그 매핑은 추정치로, 컴북스 확인 전입니다.)"
|
||||
return reason
|
||||
|
||||
def _assign_tags(self, hit: SimilarityHit, legacy: InfringementType) -> list[InfringementTag]:
|
||||
def _assign_tags(self, hit: SimilarityHit, legacy: InfringementType,
|
||||
exact_span: bool = False) -> list[InfringementTag]:
|
||||
"""삼중 유사도 분포 → 10종 법령 태그(주/보조) 매핑.
|
||||
|
||||
규칙(PDF IX장 매핑표 기반):
|
||||
@@ -679,6 +682,7 @@ class PlagiarismDetector:
|
||||
- lemma만 매우 높음 → 인용 표시 누락(주 보조)
|
||||
- 인물 일치도 매우 높음(서사·구조 차용) → 2차적저작물작성권(주) + 자기창작인양표시(보조)
|
||||
- 구조 미달 가공 신호 (text 낮음 + lemma 중간) → 2차적저작물 미달 가공
|
||||
- 위 어디에도 안 걸리지만 35자 이상 연속 일치(부분 복제) → 복제권 + 인용 누락(주)
|
||||
|
||||
주 태그는 케이스 후보를 좁히는 유일한 입력이므로, 유사도 분포로 판단할 수
|
||||
있는 쟁점은 보조가 아니라 주 태그로 낸다. 반대로 게재 사실·편집 개입·성명
|
||||
@@ -727,6 +731,13 @@ class PlagiarismDetector:
|
||||
secondary.append("derivative_work")
|
||||
secondary.append("citation_missing")
|
||||
|
||||
# 원고 일부만 그대로 옮기면 전체 유사도는 중간이지만, 35자 이상 연속 일치는
|
||||
# 그 자체로 복제 근거다. 주 태그가 비면 분류 코드도 비므로 통째 복제와 같게 둔다.
|
||||
elif exact_span:
|
||||
primary.append("reproduction")
|
||||
primary.append("citation_missing")
|
||||
secondary.append("public_transmission")
|
||||
|
||||
# 낮은 매칭이지만 임계 통과한 경우
|
||||
else:
|
||||
secondary.append("reproduction")
|
||||
|
||||
@@ -134,3 +134,34 @@ def test_case_reason_explains_tags_ties_and_draft_mapping():
|
||||
assert 'text=0.45' in reason and 'M1, M10 중 하나로' in reason
|
||||
assert '판단할 것: Q3' in reason and '추정치' not in reason
|
||||
assert '추정치' in PlagiarismDetector._case_reason(m10, ['reproduction'], hit, tie)
|
||||
|
||||
|
||||
def test_partial_verbatim_copy_gets_case_code(tmp_path):
|
||||
"""원고 일부만 그대로 옮긴 경우 전체 유사도가 중간이라도 분류 코드가 비면 안 된다.
|
||||
|
||||
35자 이상 연속 일치로 채택된 매칭인데 주 태그가 없어 case_id 가 null 로
|
||||
내려가던 문제의 회귀 테스트. 원문·원고는 모두 가짜 문장이다.
|
||||
"""
|
||||
from app.api.schemas import DetectRequest
|
||||
from app.core.config import get_settings
|
||||
from app.engine.detector import PlagiarismDetector
|
||||
from app.engine.persistent_index import PersistentCorpusIndex
|
||||
from scripts.run_precision_eval import build_corpus
|
||||
source = ("나는 바닷가 작은 마을에서 태어났다. 아버지는 새벽마다 배를 타고 나가셨고 어머니는 "
|
||||
"시장에서 생선을 파셨다. 열 살 무렵 처음으로 아버지의 배에 올랐던 날, 바다 위로 "
|
||||
"떠오르던 해를 보며 나도 언젠가 저 수평선 너머로 가겠다고 다짐했다. 중학교를 마치고 "
|
||||
"도시로 올라와 인쇄소에서 일을 배웠다. 밤마다 활자를 정리하며 책 냄새를 맡는 것이 "
|
||||
"그렇게 좋을 수가 없었다.")
|
||||
query = ("어린 시절 이야기를 조금 적어 본다. 열 살 무렵 처음으로 아버지의 배에 올랐던 날, "
|
||||
"바다 위로 떠오르던 해를 보며 나도 언젠가 저 수평선 너머로 가겠다고 다짐했다. "
|
||||
"그 뒤로 나는 늘 바다를 그리워하며 살았다.")
|
||||
db, index = tmp_path / 'corpus.sqlite3', tmp_path / 'index'
|
||||
build_corpus([{'author': 'sample', 'segment_id': 'sample-src-001', 'text': source}], db)
|
||||
PersistentCorpusIndex(db, index).sync()
|
||||
det = PlagiarismDetector(get_settings().model_copy(update={
|
||||
'use_persistent_index': True, 'corpus_db_path': str(db),
|
||||
'persistent_index_dir': str(index)}))
|
||||
match = det.detect_request(DetectRequest(doc_id='q', text=query)).matches[0]
|
||||
assert 'exact_span' in match.match_reasons
|
||||
assert match.case_id == 'M1'
|
||||
assert [c.case_id for c in match.case_candidates] == ['M1']
|
||||
Reference in new issue
Block a user