feat: expand infringement case matching to v1.3 precedent mapping
태그 동점 시 첫 케이스만 반환해 나머지를 버리던 문제를 고친다. A1·A2·A3·A4·A5·A6·A15 는 주/보조 태그가 동일하고 실제 구별자는 원본의 종류라 태그로 좁혀지지 않는다. find_case -> find_cases 로 바꿔 동점군을 전부 내보내고, 확정은 사람이 원본 종류로 한다. - cases_v1.3.json 신설(v1.2 삭제): 39건 전부에 대표판례·처리구분(●/○) 적재. 판례 미지정 10건은 사유를 값으로 남긴다. - detectable_internal 10 -> 19건 (v1.3 IX장 총괄표 ● 기준으로 정정) - _assign_tags 주 태그 조합 3 -> 5종. 유사도로 판단 가능한 쟁점만 주 태그로 낸다. 도달 케이스 3 -> 16건(● 19건 중). - B3·C1·D1 은 게재 사실·편집 개입·성명표시가 필요해 텍스트로 알 수 없다. 추측하지 않고 LegalContext 대기로 두며 경계를 테스트로 고정한다. - 케이스 수 검증을 38~39 범위에서 39 로 고정. v1.3 본문 통계 줄(●16/○22=38)이 같은 문서의 표(●19/○20=39)와 어긋난 것이 38/39 혼재의 원인이었다. - docs/PRECEDENT_SOURCE_GAP.md: 대표판례이나 적재본에 없어 출처를 제시할 수 없는 14건. 응답에서도 precedents_without_source 로 구분한다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
aaabbdd8c6
commit
52a0fdcdf0
10 files changed
+1120
-133
No files matched your search
@@ -41,3 +41,47 @@ def test_out_of_scope_excluded_from_request():
|
||||
ids = {x["case_id"] for x in rep["data_request_list"]}
|
||||
assert "C1" not in ids
|
||||
assert rep["need_data_cases"] == 0
|
||||
|
||||
|
||||
# --- 태그 → 케이스 도달 범위 회귀 (v1.3) ---------------------------------
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from app.engine.taxonomy import load_taxonomy
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
#: _assign_tags 가 실제로 낼 수 있는 주 태그 조합 전부.
|
||||
#: 이 목록이 곧 케이스 도달 범위의 상한이므로 조합이 바뀌면 여기도 바뀌어야 한다.
|
||||
_EMITTED_PRIMARY = [
|
||||
["reproduction", "citation_missing"],
|
||||
["reproduction", "derivative_work"],
|
||||
["derivative_work", "citation_missing"],
|
||||
["derivative_work", "substandard_derivative"],
|
||||
["reproduction"],
|
||||
]
|
||||
|
||||
|
||||
def _reachable():
|
||||
tax = load_taxonomy(ROOT / "data/taxonomy")
|
||||
return {c.case_id for combo in _EMITTED_PRIMARY for c in tax.find_cases(combo)}
|
||||
|
||||
|
||||
def test_reachable_cases_cover_most_technical_detection_cases():
|
||||
"""v1.3 ● 19건 중 16건이 태그만으로 후보에 오른다.
|
||||
|
||||
남은 B3·C1·D1 은 게재 사실·편집 개입·성명표시처럼 텍스트에서 알 수 없는
|
||||
사실이 필요해 LegalContext 없이는 도달할 수 없다. 이 경계를 고정한다.
|
||||
"""
|
||||
tax = load_taxonomy(ROOT / "data/taxonomy")
|
||||
detectable = {c.case_id for c in tax.cases if c.detectable_internal}
|
||||
reachable = _reachable()
|
||||
assert detectable - reachable == {"B3", "C1", "D1"}
|
||||
assert len(reachable & detectable) == 16
|
||||
|
||||
|
||||
def test_no_tie_group_is_silently_collapsed():
|
||||
"""동점군이 2건 이상이면 전부 반환된다 — 하나만 남으면 나머지가 사장된다."""
|
||||
tax = load_taxonomy(ROOT / "data/taxonomy")
|
||||
assert len(tax.find_cases(["reproduction", "citation_missing"])) == 7
|
||||
assert len(tax.find_cases(["derivative_work", "substandard_derivative"])) == 2
|
||||
@@ -27,9 +27,11 @@ def test_taxonomy_loads_10_tags_and_cases():
|
||||
tax = load_taxonomy(ROOT / "data/taxonomy")
|
||||
assert tax is not None
|
||||
assert len(tax.meta_tags) == 10, f"PDF IV장: 10종 메타 태그 필요, 현재 {len(tax.meta_tags)}"
|
||||
# PDF 본문에는 "38개"라고 명시되어 있으나 그룹별 통계
|
||||
# (A27+B4+C3+D1+E2+X2)는 39건이므로 그룹별 통계를 기준으로 검증
|
||||
assert 38 <= len(tax.cases) <= 39, f"PDF IX장: 38~39 케이스, 현재 {len(tax.cases)}"
|
||||
# v1.3 IX장 총괄표 본문의 통계 줄은 "●16/○22 = 38"로 적혀 있으나 표를 실제로
|
||||
# 세면 ●19/○20 = 39 다. 표를 기준으로 고정한다.
|
||||
assert len(tax.cases) == 39, f"v1.3 IX장 총괄표: 39 케이스, 현재 {len(tax.cases)}"
|
||||
assert sum(c.detectable_internal for c in tax.cases) == 19
|
||||
assert sum(c.handling == "technical_detection" for c in tax.cases) == 19
|
||||
|
||||
|
||||
def test_taxonomy_has_required_legal_tags():
|
||||
@@ -51,12 +53,22 @@ def test_taxonomy_case_groups():
|
||||
assert len(a_cases) == 27, f"PDF: A그룹(저자 가해) 27건, 현재 {len(a_cases)}"
|
||||
|
||||
|
||||
def test_case_mapping_finds_a1_for_reproduction_citation():
|
||||
def test_case_mapping_returns_full_tie_group_not_one_arbitrary_pick():
|
||||
"""reproduction+citation_missing 은 7개 케이스가 주/보조 태그까지 동일하다.
|
||||
|
||||
하나만 고르면 나머지 6건이 결과에 영원히 등장하지 않으므로 동점군을 모두 낸다.
|
||||
"""
|
||||
tax = load_taxonomy(ROOT / "data/taxonomy")
|
||||
# A1: 시·노래 가사 본문 무단 인용 — 주 태그: reproduction, citation_missing
|
||||
case = tax.find_case(["reproduction", "citation_missing"])
|
||||
assert case is not None
|
||||
assert case.case_id.startswith("A"), f"reproduction+citation은 A그룹 매칭 기대, got {case.case_id}"
|
||||
ids = [c.case_id for c in tax.find_cases(["reproduction", "citation_missing"])]
|
||||
assert set(ids) == {"A1", "A2", "A3", "A4", "A5", "A6", "A15"}, ids
|
||||
assert all(i.startswith("A") for i in ids)
|
||||
|
||||
|
||||
def test_every_case_carries_v13_precedent_mapping():
|
||||
"""39건 전부가 대표판례를 갖거나, 없는 이유를 명시한다. 빈칸은 허용하지 않는다."""
|
||||
tax = load_taxonomy(ROOT / "data/taxonomy")
|
||||
for c in tax.cases:
|
||||
assert c.representative_precedents or c.representative_precedent_note, c.case_id
|
||||
|
||||
|
||||
def test_high_risk_cases_marked():
|
||||
|
||||
Reference in new issue
Block a user