WP44: structured-output schema fix (maxItems), metrics array fix
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 changed file +2 −2
modified
taxonomy/validate_sample.py
+2 −2
@@ -7,7 +7,7 @@ API key: read from the file given by --env-file (never from the repository); the | ||
| 7 | 7 | import argparse, json, os, random, time, re, duckdb, yaml, pandas as pd, numpy as np |
| 8 | 8 | |
| 9 | 9 | SCHEMA = {"type": "object", "properties": {"ratings": {"type": "array", "items": {"type": "object", "properties": { |
| 10 | − "work_id": {"type": "integer"}, "categories": {"type": "array", "items": {"type": "string"}, "maxItems": 5}, | |
| 10 | + "work_id": {"type": "integer"}, "categories": {"type": "array", "items": {"type": "string"}}, | |
| 11 | 11 | "primary": {"type": ["string", "null"]}, "confidence": {"type": "number"}, "rationale": {"type": "string"}}, |
| 12 | 12 | "required": ["work_id", "categories", "primary", "confidence", "rationale"], "additionalProperties": False}}}, |
| 13 | 13 | "required": ["ratings"], "additionalProperties": False} |
@@ -80,7 +80,7 @@ def metrics(root, ontology): | ||
| 80 | 80 | rows = [json.loads(l) for l in open(os.path.join(d, f))] |
| 81 | 81 | raters[f[8:-6]] = {r["work_id"]: r for r in rows} |
| 82 | 82 | ids = [w for w in df.work_id if all(w in r for r in raters.values())] |
| 83 | − rule = {r.work_id: set(r.rule_categories or []) for r in df.itertuples()} | |
| 83 | + rule = {r.work_id: set(list(r.rule_categories) if r.rule_categories is not None else []) for r in df.itertuples()} | |
| 84 | 84 | rule_p = {r.work_id: r.primary_category for r in df.itertuples()} |
| 85 | 85 | M = {"n_rated_by_all": len(ids), "raters": list(raters)} |
| 86 | 86 | def prf(ref_sets, pred_sets): |
| 87 | 87 | |