File size: 1,287 Bytes
3f6016e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from __future__ import annotations

import json
import sqlite3
from pathlib import Path


def main() -> None:
    db_path = Path("dev.db")
    if not db_path.is_file():
        raise SystemExit("dev.db not found in cwd")

    con = sqlite3.connect(str(db_path))
    cur = con.cursor()
    cur.execute("select report_id, section_code, provenance from report_sections")
    rows = cur.fetchall()

    counts: dict[int, int] = {}
    examples: dict[int, tuple[str, str]] = {}

    for report_id, section_code, prov in rows:
        try:
            raw = json.loads(prov or "null")
        except Exception:
            continue
        meta = raw.get("meta", {}) if isinstance(raw, dict) else {}
        trx = meta.get("ai_transparency", {}) if isinstance(meta.get("ai_transparency"), dict) else {}
        v = trx.get("ai_involvement_percent", None)
        if not isinstance(v, int):
            continue
        counts[v] = counts.get(v, 0) + 1
        examples.setdefault(v, (str(report_id), str(section_code)))

    print("ai_involvement_percent histogram (from persisted meta.ai_transparency):")
    for k in sorted(counts):
        ex = examples.get(k)
        print(f"  {k:>3}%: {counts[k]:>4} rows  (e.g. report={ex[0]} section={ex[1]})")


if __name__ == "__main__":
    main()