feat: add anonymized infringement batch reporting

This commit is contained in:
HyeongBaeYang committed 2026-09-02 09:23:45 +09:00
1 parent d5e0f4346d
commit c35c5aabfc
6 files changed
+573 -30

No files matched your search

+40
View File
@@ -315,6 +315,46 @@ class CorpusStore:
).fetchall()
return [dict(row) for row in rows]
def document_source_groups(self) -> dict[str, str]:
"""문서별 익명 작성자 그룹을 반환한다.
``author_group`` 은 수령 XLSX 적재기의 기존 필드이고, ``source_group`` 은
새 수집 원문·학습 데이터에서 쓰는 공통 필드다. 둘 다 가명 값만 허용한다.
영속 인덱스가 자기 작성자의 후보를 검색 단계에서 제외할 때 사용한다.
"""
if not self.path.exists():
return {}
with self._connect() as con:
rows = con.execute(
"SELECT document_id, metadata_json FROM documents"
).fetchall()
groups: dict[str, str] = {}
for row in rows:
metadata = json.loads(row["metadata_json"] or "{}")
group = str(
metadata.get("source_group") or metadata.get("author_group") or ""
).strip()
if group:
groups[str(row["document_id"])] = group
return groups
def documents_with_metadata(self) -> list[DocumentRecord]:
"""배치·감사용 문서 목록. 원문 세그먼트는 포함하지 않는다."""
if not self.path.exists():
return []
with self._connect() as con:
rows = con.execute(
"""SELECT document_id, title, source_path, source_sha256, metadata_json
FROM documents ORDER BY document_id"""
).fetchall()
return [DocumentRecord(
document_id=str(row["document_id"]),
title=str(row["title"]),
source_path=row["source_path"],
source_sha256=row["source_sha256"],
metadata=json.loads(row["metadata_json"] or "{}"),
) for row in rows]
def delete_document(self, document_id: str) -> bool:
if not self.path.exists():
return False