feat(style-acq T8): analyze_corpus — הסרת LIMIT 20 (כיסוי 48/48)

LIMIT 20 קבוע השמיט בשקט שליש מקורפוס דפנה מחילוץ author-features שהפרופיל
של הכותב (T0) נסמך עליו. עכשיו limit=0 (ברירת-מחדל) = כל הקורפוס; פרמטר
lim>0 אופציונלי לתקרה.

G11.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-06 19:25:13 +00:00
parent 3c68383e86
commit 5fa76a09b4

View File

@@ -109,26 +109,30 @@ SYNTHESIS_PROMPT = """\
"""
async def analyze_corpus(appeal_subtype: str = "") -> dict:
async def analyze_corpus(appeal_subtype: str = "", limit: int = 0) -> dict:
"""Analyze the style corpus and extract/update patterns.
Args:
appeal_subtype: filter by appeal subtype (e.g. 'betterment_levy', 'building_permit').
Empty string = all decisions.
limit: max decisions to analyze. 0 = ALL (T8 — full 48/48 coverage feeds the
author-features the writer's profile relies on; the old LIMIT 20 silently
dropped a third of Dafna's corpus).
Returns summary of patterns found.
"""
pool = await db.get_pool()
lim_sql = f" LIMIT {int(limit)}" if limit and limit > 0 else ""
async with pool.acquire() as conn:
if appeal_subtype:
rows = await conn.fetch(
"SELECT full_text, decision_number FROM style_corpus "
"WHERE appeal_subtype = $1 ORDER BY decision_date DESC LIMIT 20",
"WHERE appeal_subtype = $1 ORDER BY decision_date DESC" + lim_sql,
appeal_subtype,
)
else:
rows = await conn.fetch(
"SELECT full_text, decision_number FROM style_corpus ORDER BY decision_date DESC LIMIT 20"
"SELECT full_text, decision_number FROM style_corpus ORDER BY decision_date DESC" + lim_sql
)
if not rows: