File size: 2,243 Bytes
13779e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
"""Validate batch 4 JSONs and count populated fields."""
import json
import os

BASE = "/Users/rohitsar/Documents/Personal/AI Work/Insurance Sales Bot/rag/extracted"
BATCH = [
    "hdfc-ergo__total-health-plan__wordings",
    "icici-lombard__arogya-sanjeevani__wordings",
    "icici-lombard__complete-health-insurance-health-shield__wordings",
    "icici-lombard__complete-health-insurance-umbrella__wordings",
    "icici-lombard__elevate__wordings",
    "icici-lombard__health-advantedge__wordings",
    "icici-lombard__health-booster-top-up__wordings",
    "icici-lombard__health-elite-plus__wordings",
    "icici-lombard__health-shield-360-retail__cis",
    "icici-lombard__health-shield-360-retail__wordings",
    "iffco-tokio__critical-illness-benefit__wordings",
    "iffco-tokio__essential-health-plan__wordings",
    "iffco-tokio__family-health-protector__wordings",
    "iffco-tokio__health-protector-assure__wordings",
    "iffco-tokio__health-protector-plus__wordings",
    "iffco-tokio__individual-health-protector__wordings",
    "manipalcigna__prohealth-insurance-all-variants__wordings",
    "manipalcigna__prohealth-select__wordings",
    "manipalcigna__sarvah-param__brochure",
]


def is_populated(v):
    if v is None:
        return False
    if isinstance(v, (list, dict)) and len(v) == 0:
        return False
    if isinstance(v, dict):
        # CoverageItem: populated if any subfield set
        return any(is_populated(x) for x in v.values())
    if isinstance(v, str) and v.strip() == "":
        return False
    return True


total = 0
ok = 0
field_counts = []
for pid in BATCH:
    path = os.path.join(BASE, pid + ".json")
    if not os.path.exists(path):
        print(f"MISSING {pid}")
        continue
    try:
        with open(path) as f:
            data = json.load(f)
    except Exception as e:
        print(f"ERR {pid} {e}")
        continue
    ok += 1
    n_pop = sum(1 for v in data.values() if is_populated(v))
    field_counts.append((pid, n_pop, len(data)))

print(f"OK: {ok}/{len(BATCH)}")
print(f"Average populated fields: {sum(c[1] for c in field_counts)/len(field_counts):.1f}")
print()
for pid, n_pop, total_f in field_counts:
    print(f"  {pid}: {n_pop}/{total_f}")