Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 5,518 Bytes
d15f07c | 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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | # Discovery Scripts
Scripts for discovering government data sources across U.S. jurisdictions.
For **meeting PDFs**, agendas, and optional contact extraction into `data/cache/scraped_meetings`, use **`comprehensive_discovery_pipeline_jurisdiction.py`** (see its module docstring for `python -m` examples).
## Comprehensive Discovery Pipeline (legacy master discovery)
**Script:** `scripts/discovery/archive/comprehensive_discovery_pipeline.py`
Automates discovery of data sources for all U.S. cities and counties (22,000+ jurisdictions):
- Government websites
- YouTube channels (with statistics)
- Vimeo channels
- Meeting platforms (Legistar, SuiteOne, Granicus, etc.)
- Agenda portals and document systems
- Social media accounts
- Meeting schedules and archives
**Features:**
- **Wikidata Enrichment** - Automatically fills in missing data (websites, social media) from Wikidata for jurisdictions with incomplete discovery
- **Incremental Mode** - Skips already-discovered jurisdictions to save time and API costs
- **LocalView Integration** - Automatically includes known YouTube channels from LocalView database
### Usage
**Run for all jurisdictions (incremental mode):**
```bash
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --all
```
**Run for specific state:**
```bash
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --state AL
```
**Run for the 6 in-scope oral health states (AL, GA, IN, MA, WA, WI):**
```bash
# Automated script runs all 6 states sequentially with incremental mode
bash scripts/discovery/discover_oral_health_states.sh
```
Or run individual states manually:
```bash
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --state AL
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --state GA
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --state IN
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --state MA
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --state WA
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --state WI
```
**Run for top N cities by population:**
```bash
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --top 100
```
**Disable incremental mode (rediscover all):**
```bash
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --all --no-incremental
```
**Change refresh threshold (default 90 days):**
```bash
python scripts/discovery/archive/comprehensive_discovery_pipeline.py --all --refresh-days 30
```
### Incremental Mode
By default, the script runs in **incremental mode**:
- Skips jurisdictions already discovered
- Only re-processes jurisdictions with stale data (older than 90 days by default)
- Significantly reduces API costs and processing time
- Use `--no-incremental` to force rediscovery of all jurisdictions
### Wikidata Enrichment
The pipeline automatically enriches incomplete discoveries using **Wikidata** (free, no API key required):
**What Wikidata Provides:**
- Official government website URLs
- Population data
- Social media accounts (Facebook, Twitter, YouTube channel IDs)
**When It's Used:**
- Automatically applied when primary discovery fails or is incomplete
- Especially helpful for smaller jurisdictions (CDPs, small cities)
- Example: "Alexandria CDP, AL" might have no direct .gov domain, but Wikidata may have its official Facebook page
**Benefits:**
- ✅ Completely free (no API limits)
- ✅ Community-maintained (Wikipedia's structured data)
- ✅ High quality for major cities
- ⚠️ May have gaps for very small jurisdictions
### Options
- `--state` - Filter to specific state (e.g., AL, CA, TX)
- `--top N` - Limit to top N jurisdictions by population
- `--all` - Process all jurisdictions (warning: 20,000+)
- `--youtube-api-key` - YouTube Data API v3 key for accurate statistics
- `--max-concurrent` - Maximum concurrent requests (default: 10)
- `--no-incremental` - Disable incremental mode (rediscover all)
- `--refresh-days` - Days before discovery is considered stale (default: 90)
### Output
Discovery results are saved to:
- `data/gold/jurisdictions_details.parquet` - Consolidated jurisdiction details including:
- Website URLs
- YouTube channel counts and data
- Meeting platforms detected
- Social media accounts
- Discovery timestamps
- Completeness scores
- `data/bronze/discovered_sources/discovery_results_*.json` - Detailed JSON output
- `data/bronze/discovered_sources/discovery_summary_*.csv` - Summary CSV reports
## Other Discovery Tools
### Discover Oral Health States
**Script:** `discover_oral_health_states.sh`
Convenience script that runs comprehensive discovery for all 6 in-scope oral health states (AL, GA, IN, MA, WA, WI) sequentially with incremental mode enabled.
```bash
bash scripts/discovery/discover_oral_health_states.sh
```
### URL Discovery Agent
**Script:** `url_discovery_agent.py`
Agent-based URL discovery using web search and scraping.
### Platform Detector
**Script:** `platform_detector.py`
Detects meeting platforms (Legistar, Granicus, etc.) from URLs.
### Batch Processor
**Script:** `batch_processor.py`
Batch processing for large-scale jurisdiction discovery operations.
### External URL Datasets
**Script:** `external_url_datasets.py`
Imports URLs from external curated datasets (City Scrapers, LocalView, etc.).
### Curated Sources
**Script:** `curated_sources.py`
Manages manually curated high-quality data sources.
|