feat: 수령 자서전 데이터 파이프라인과 맞춤 요약 추가
This commit is contained in:
1 parent
5386222f1b
commit
946e9e9474
17 files changed
+437
-48
No files matched your search
@@ -0,0 +1,68 @@
|
||||
"""수령 원고 익명화·그룹 분리 회귀 테스트."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from openpyxl import Workbook
|
||||
|
||||
from app.engine.training_data import (
|
||||
pseudonymous_id,
|
||||
redact_direct_identifiers,
|
||||
sanitize_prompt_metadata,
|
||||
)
|
||||
from scripts.build_ai_training_dataset import load_human_from_xlsx
|
||||
|
||||
|
||||
def test_pseudonymous_id_is_stable_and_salt_scoped():
|
||||
assert pseudonymous_id("writer@example.com", "salt-a") == pseudonymous_id(
|
||||
"writer@example.com", "salt-a"
|
||||
)
|
||||
assert pseudonymous_id("writer@example.com", "salt-a") != pseudonymous_id(
|
||||
"writer@example.com", "salt-b"
|
||||
)
|
||||
assert "writer" not in pseudonymous_id("writer@example.com", "salt-a")
|
||||
|
||||
|
||||
def test_direct_identifiers_are_redacted():
|
||||
text = "연락처 writer@example.com, 010-1234-5678, 900101-1234567"
|
||||
redacted = redact_direct_identifiers(text)
|
||||
assert "writer@example.com" not in redacted
|
||||
assert "010-1234-5678" not in redacted
|
||||
assert "900101-1234567" not in redacted
|
||||
|
||||
|
||||
def test_prompt_metadata_removes_named_autobiography_title():
|
||||
assert sanitize_prompt_metadata("홍길동의 자서전") == "익명 작성자의 자서전"
|
||||
|
||||
|
||||
def test_received_schema_uses_author_group_without_raw_identifier(tmp_path: Path):
|
||||
path = tmp_path / "received.xlsx"
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "bio"
|
||||
ws.append(["id", "자서전 제목", "에피소드 제목", "에피소드 본문"])
|
||||
ws.append([
|
||||
"writer@example.com", "홍길동의 자서전", "첫 직장",
|
||||
"이메일 writer@example.com으로 연락했다. " + "인생을 기록했다. " * 20,
|
||||
])
|
||||
wb.save(path)
|
||||
|
||||
records = load_human_from_xlsx(
|
||||
path,
|
||||
text_column="에피소드 본문",
|
||||
book_column="자서전 제목",
|
||||
id_column="id",
|
||||
sheet=None,
|
||||
min_chars=100,
|
||||
group_column="id",
|
||||
anonymization_salt="test-salt",
|
||||
provenance="combooks_confirmed_human",
|
||||
)
|
||||
assert len(records) == 1
|
||||
record = records[0]
|
||||
assert record.source_group.startswith("author:")
|
||||
assert record.book == ""
|
||||
assert "writer@example.com" not in record.text
|
||||
assert record.meta["human_verified"] is True
|
||||
assert record.meta["ai_assistance"] is False
|
||||
Reference in new issue
Block a user