File size: 2,878 Bytes
93d3cf7
d8b26e4
93d3cf7
d8b26e4
 
0f6dc04
d8b26e4
 
 
 
 
 
 
93d3cf7
d8b26e4
 
 
 
 
 
 
 
 
 
 
 
93d3cf7
d8b26e4
 
 
 
 
93d3cf7
d8b26e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# SafeVixAI β€” Data Acquisition Scripts πŸ”¬

These scripts are the **raw data pipeline** that built the 3.6GB SafeVixAI dataset.
All scripts here are **pure Python** β€” they require no database, no Redis, no PostGIS.

> Scripts are mirrored from the [SafeVixAI main repo](https://github.com/SafeVixAI/SafeVixAI) and organized by their origin folder.

---

## πŸ“ Structure

```
scripts/
β”œβ”€β”€ scripts/data/             ← from SafeVixAI/scripts/data/
β”‚   β”œβ”€β”€ fetch_*.py            ← Overpass GIS fetchers (basic version)
β”‚   β”œβ”€β”€ _overpass_utils.py    ← Core GIS utility
β”‚   β”œβ”€β”€ download_legal_pdfs.py
β”‚   β”œβ”€β”€ extract_morth2022_tables.py
β”‚   β”œβ”€β”€ seed_blackspots.py
β”‚   β”œβ”€β”€ bootstrap_local_data.py
β”‚   β”œβ”€β”€ verify_data.py
β”‚   β”œβ”€β”€ inspect_zips.py
β”‚   β”œβ”€β”€ audit_env.py
β”‚   β”œβ”€β”€ check_all_scripts.py
β”‚   └── setup_kaggle.ps1
β”‚
β”œβ”€β”€ backend/data/             ← from SafeVixAI/backend/scripts/data/
β”‚   β”œβ”€β”€ seed_violations.py    ← MVA 2019 traffic fine normalizer
β”‚   β”œβ”€β”€ prepare_road_sources.py
β”‚   β”œβ”€β”€ sample_pmgsy.py
β”‚   └── road_sources.example.json
β”‚
└── chatbot_service/data/     ← from SafeVixAI/chatbot_service/scripts/data/
    β”œβ”€β”€ _overpass_utils.py    ← ⭐ Pro version (retries + backoff)
    └── fetch_*.py            ← ⭐ Pro fetchers (use these over scripts/data/)
```

---

## πŸš€ Recommended Run Order

```bash
# Install dependencies first
pip install requests pdfplumber

# 1. Setup Kaggle API (one-time)
pwsh scripts/scripts/data/setup_kaggle.ps1

# 2. Fetch all emergency services (use Pro versions)
python scripts/chatbot_service/data/fetch_hospitals.py
python scripts/chatbot_service/data/fetch_police.py
python scripts/chatbot_service/data/fetch_ambulance.py
python scripts/chatbot_service/data/fetch_blood_banks.py
python scripts/chatbot_service/data/fetch_fire.py

# 3. Download legal documents
python scripts/scripts/data/download_legal_pdfs.py

# 4. Extract MoRTH accident tables from PDFs
python scripts/scripts/data/extract_morth2022_tables.py

# 5. Normalize accident blackspot data
python scripts/scripts/data/seed_blackspots.py

# 6. Normalize traffic violations (MVA 2019)
python scripts/backend/data/seed_violations.py

# 7. Verify everything is correct
python scripts/scripts/data/verify_data.py
```

---

## ⭐ Pro vs Basic Fetchers

| Feature | `scripts/scripts/data/fetch_*.py` | `scripts/chatbot_service/data/fetch_*.py` |
|---|---|---|
| Retry logic | ❌ | βœ… |
| Exponential backoff | ❌ | βœ… |
| Indian GIS precision | Basic | Enhanced |
| Extra fields (email, postcode) | ❌ | βœ… |

**Always prefer `chatbot_service/data/` versions** for data acquisition.

---

## πŸ“¦ Dependencies

```
pip install -r requirements.txt
```

See `requirements.txt` in the Hub root.