Add claim_type field: distinguish claims vs responses vs replies

Legal documents have 3 types of assertions:
- claim: from appeal documents (כתב ערר)
- response: from original responses (כתב תשובה)
- reply: from supplementary responses (תגובה, השלמת טיעון)

DB: added claim_type column to claims table
Extractor: _infer_claim_type() auto-detects from doc_type + title
Updated existing 113 records: 29 claims, 28 responses, 56 replies

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-04 15:35:16 +00:00
parent 328436f56d
commit 96ea54dc6e
2 changed files with 27 additions and 2 deletions

View File

@@ -114,6 +114,25 @@ async def extract_claims_with_ai(
return [c for c in claims if "party_role" in c and "claim_text" in c]
def _infer_claim_type(doc_type: str, source_name: str) -> str:
"""Determine claim_type from document type and title.
- 'claim' = from appeal documents (כתב ערר)
- 'response' = from original response documents (כתב תשובה)
- 'reply' = from supplementary responses (תגובה, השלמת טיעון)
"""
name_lower = source_name.lower() if source_name else ""
if doc_type == "appeal" or "כתב ערר" in name_lower:
return "claim"
if "כתב תשובה" in name_lower:
return "response"
if any(kw in name_lower for kw in ["תגובת", "השלמת טיעון", "תגובה"]):
return "reply"
if doc_type == "response":
return "response"
return "claim"
# ── Regex-based extraction (from existing decisions) ──────────────
PARTY_PATTERNS = [
@@ -229,6 +248,11 @@ async def extract_and_store_claims(
if not claims:
return {"status": "no_claims", "total": 0, "source": source_name}
# Determine claim_type from document type and title
claim_type = _infer_claim_type(doc_type, source_name)
for c in claims:
c["claim_type"] = claim_type
stored = await db.store_claims(case_id, claims, source_document=source_name)
# Summarize by role