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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
# πŸ’° COST-EFFECTIVE STORAGE STRATEGY (Personal Budget)

**TL;DR: Use Hugging Face Datasets - it's FREE and unlimited for public data!**

---

## 🎯 THE PROBLEM

**Challenge:**
- Need to process 22,000+ jurisdictions
- Each jurisdiction has: agendas, minutes, videos, social media
- Estimated total: **10-50 TB** of raw content
- Limited local storage + personal budget

**Solution: Don't store everything locally!**

---

## βœ… RECOMMENDED STRATEGY: HUGGING FACE DATASETS

### Why Hugging Face?

1. **πŸ†“ FREE** - Unlimited storage for public datasets
2. **🌐 Cloud-based** - No local storage needed
3. **πŸ“Š Versioned** - Git-based dataset management
4. **πŸ” Searchable** - Built-in search and filtering
5. **🀝 Shareable** - Public datasets help research community
6. **⚑ Fast** - Optimized for large datasets

### ⚠️ CRITICAL: File Limits

**Hugging Face has repository limits:**
- Files per folder: <10,000
- Total files per repo: <100,000
- Large datasets: Use Parquet or WebDataset format

**Your scale (22M files) exceeds limits!**

**Solution: Use Parquet format**
- 22 million PDFs β†’ 50 Parquet files βœ…
- See detailed guide: [HUGGINGFACE_FILE_LIMITS.md](HUGGINGFACE_FILE_LIMITS.md)

### What to Store

**Store ONLY processed/filtered data, not raw content:**

βœ… **Store:**
- Extracted text from PDFs
- Meeting metadata (date, title, URL)
- Oral health-related snippets
- Social media links
- Discovery results (JSON)

❌ **Don't Store:**
- Full video files (link to YouTube instead)
- Full PDF files (store text + source URL)
- Website HTML dumps
- Duplicate content

---

## πŸ“Š STORAGE ESTIMATES

### Raw Content (DON'T download all):
```
Videos:        5,000 channels Γ— 100 videos Γ— 500 MB = 250 TB  ❌
PDFs:          15,000 jurisdictions Γ— 1,000 docs Γ— 2 MB = 30 TB  ❌
Social media:  18,000 accounts Γ— archives = 5 TB  ❌
TOTAL RAW:     ~285 TB  🚫 TOO EXPENSIVE!
```

### Processed Content (Hugging Face approach):
```
Discovery data:     22,000 jurisdictions Γ— 50 KB = 1.1 GB  βœ…
Meeting metadata:   500,000 meetings Γ— 5 KB = 2.5 GB  βœ…
Extracted text:     500,000 docs Γ— 50 KB = 25 GB  βœ…
Oral health subset: 50,000 relevant docs Γ— 100 KB = 5 GB  βœ…
TOTAL PROCESSED:    ~34 GB  βœ… TOTALLY FREE on Hugging Face!
```

**Savings: 285 TB β†’ 34 GB = 99.99% reduction!**

---

## πŸš€ STEP-BY-STEP: HUGGING FACE WORKFLOW

### Step 1: Create Free Hugging Face Account

```bash
# Sign up at https://huggingface.co/join
# Create account (FREE)
# Get your access token from https://huggingface.co/settings/tokens
```

### Step 2: Install Hugging Face Libraries

```bash
pip install huggingface_hub datasets
```

### Step 3: Create Your Dataset

```python
from huggingface_hub import HfApi, create_repo
from datasets import Dataset
import pandas as pd

# Login
from huggingface_hub import login
login(token="hf_YOUR_TOKEN")  # Get from https://huggingface.co/settings/tokens

# Create dataset repository
repo_name = "oral-health-policy-data"
create_repo(
    repo_id=f"your-username/{repo_name}",
    repo_type="dataset",
    private=False  # Public = FREE unlimited storage!
)

# Upload discovery results
df = pd.read_csv('data/bronze/discovered_sources/discovery_summary_final.csv')
dataset = Dataset.from_pandas(df)
dataset.push_to_hub(f"your-username/{repo_name}", split="discovery")

print("βœ… Dataset uploaded to Hugging Face!")
print(f"View at: https://huggingface.co/datasets/your-username/{repo_name}")
```

### Step 4: Process-and-Upload Pipeline

**DON'T download everything locally first!**

Instead, use this streaming approach:

```python
import httpx
import tempfile
from pathlib import Path

async def process_jurisdiction_streaming(jurisdiction):
    """
    Process jurisdiction WITHOUT storing locally:
    1. Download agenda PDF
    2. Extract text
    3. Filter for oral health keywords
    4. Upload to Hugging Face
    5. Delete local file
    """
    
    results = []
    
    # Get agenda portal URLs
    agendas = jurisdiction['agenda_portals']
    
    for agenda_url in agendas:
        # Download to temporary file
        with tempfile.NamedTemporaryFile(delete=False, suffix='.pdf') as tmp:
            async with httpx.AsyncClient() as client:
                response = await client.get(agenda_url)
                tmp.write(response.content)
                tmp_path = tmp.name
        
        # Extract text (using PyPDF2 or similar)
        text = extract_text_from_pdf(tmp_path)
        
        # Filter for oral health content
        keywords = ['fluoride', 'dental', 'oral health', 'water treatment']
        if any(kw in text.lower() for kw in keywords):
            results.append({
                'jurisdiction': jurisdiction['name'],
                'state': jurisdiction['state'],
                'url': agenda_url,
                'text': text,
                'date': extract_date(text),
                'relevant': True
            })
        
        # Delete local file immediately
        Path(tmp_path).unlink()
    
    # Upload batch to Hugging Face
    if results:
        upload_to_huggingface(results)
    
    return len(results)
```

---

## πŸ’‘ COST BREAKDOWN: FREE OPTIONS

### Option 1: Hugging Face (RECOMMENDED)

| Item | Cost | Storage |
|------|------|---------|
| **Public datasets** | **FREE** | **UNLIMITED** |
| Private datasets | FREE | 100 GB |
| Bandwidth | FREE | Unlimited downloads |
| Processing | FREE | Use local computer |

**Total: $0/month** βœ…

### Option 2: GitHub + Hugging Face

| Item | Cost | Storage |
|------|------|---------|
| GitHub (discovery data) | FREE | 1 GB |
| Hugging Face (processed text) | FREE | Unlimited |
| GitHub LFS (large files) | $5/month | 50 GB |

**Total: $0-5/month** βœ…

### Option 3: Cloud Storage (if needed)

**Only for temporary processing:**

| Provider | Free Tier | After Free Tier |
|----------|-----------|-----------------|
| **AWS S3** | 5 GB for 12 months | $0.023/GB/month |
| **Google Cloud** | 5 GB always free | $0.020/GB/month |
| **Azure Blob** | 5 GB for 12 months | $0.018/GB/month |

**Cost for 34 GB:** ~$0.60/month βœ…

---

## 🎯 RECOMMENDED WORKFLOW

### Phase 1: Discovery (Run Locally)

```bash
# Run discovery for all jurisdictions
python discovery/comprehensive_discovery_pipeline.py --all

# Output: ~1 GB of JSON/CSV (fits on laptop!)
# Upload to Hugging Face immediately
```

### Phase 2: Content Processing (Stream & Upload)

```python
# For each jurisdiction:
for jurisdiction in all_jurisdictions:
    # 1. Download one PDF
    pdf = download_pdf(jurisdiction.agenda_url)
    
    # 2. Extract text
    text = extract_text(pdf)
    
    # 3. Check if oral health-related
    if is_relevant(text):
        # 4. Upload to Hugging Face
        upload_to_hf(text, metadata)
    
    # 5. Delete local file
    delete(pdf)
    
    # Local storage stays at ~100 MB (just temp files)!
```

**Your laptop never stores more than a few hundred MB!**

### Phase 3: Analysis (Cloud or Local)

```python
# Download ONLY relevant subset from Hugging Face
from datasets import load_dataset

# Load just oral health documents
dataset = load_dataset("your-username/oral-health-policy-data", split="relevant")

# This might be only 5 GB (totally manageable!)
print(f"Total documents: {len(dataset)}")

# Analyze locally or in Colab (FREE GPU!)
```

---

## πŸ†“ FREE RESOURCES YOU CAN USE

### 1. Hugging Face Datasets
- **Storage:** Unlimited (public datasets)
- **Cost:** FREE
- **Use:** Primary storage for all processed data

### 2. Google Colab
- **Compute:** FREE GPU/TPU (15 GB RAM)
- **Cost:** FREE (or $10/month for Pro)
- **Use:** Process PDFs, run analysis
- **Storage:** 15 GB on Google Drive (FREE)

### 3. GitHub
- **Storage:** 1 GB (100 GB with LFS for $5/month)
- **Cost:** FREE for public repos
- **Use:** Code + discovery results

### 4. Internet Archive (archive.org)
- **Storage:** Unlimited (for public documents)
- **Cost:** FREE
- **Use:** Mirror government documents

---

## πŸ“¦ SAMPLE: UPLOAD TO HUGGING FACE

### Create Upload Script

```python
#!/usr/bin/env python3
"""
upload_to_huggingface.py - Stream processed data to Hugging Face
"""

from datasets import Dataset, DatasetDict
from huggingface_hub import login
import pandas as pd
from pathlib import Path

# Configuration
HF_TOKEN = "hf_YOUR_TOKEN"  # From https://huggingface.co/settings/tokens
HF_REPO = "your-username/oral-health-policy-data"

def upload_discovery_results():
    """Upload discovery results (JSON/CSV)"""
    
    login(token=HF_TOKEN)
    
    # Load discovery data
    discovery_dir = Path("data/bronze/discovered_sources")
    
    # Load all discovery CSVs
    all_data = []
    for csv_file in discovery_dir.glob("*.csv"):
        df = pd.read_csv(csv_file)
        all_data.append(df)
    
    # Combine and upload
    combined = pd.concat(all_data, ignore_index=True)
    dataset = Dataset.from_pandas(combined)
    
    dataset.push_to_hub(HF_REPO, split="discovery")
    
    print(f"βœ… Uploaded {len(combined)} jurisdictions to Hugging Face")
    print(f"View at: https://huggingface.co/datasets/{HF_REPO}")

def upload_meeting_data(meetings_df):
    """Upload processed meeting data"""
    
    # Convert to dataset
    dataset = Dataset.from_pandas(meetings_df)
    
    # Upload
    dataset.push_to_hub(HF_REPO, split="meetings")
    
    print(f"βœ… Uploaded {len(meetings_df)} meetings")

def upload_oral_health_subset(filtered_df):
    """Upload filtered oral health content"""
    
    dataset = Dataset.from_pandas(filtered_df)
    dataset.push_to_hub(HF_REPO, split="oral_health")
    
    print(f"βœ… Uploaded {len(filtered_df)} oral health documents")

if __name__ == "__main__":
    upload_discovery_results()
```

### Run Upload

```bash
# Set your token
export HF_TOKEN="hf_YOUR_TOKEN"

# Upload discovery results
python scripts/upload_to_huggingface.py

# View your dataset
# https://huggingface.co/datasets/your-username/oral-health-policy-data
```

---

## πŸ’° TOTAL COST ESTIMATE

### Personal Budget Approach (RECOMMENDED)

| Component | Cost | Notes |
|-----------|------|-------|
| **Hugging Face** | **$0/month** | Public datasets = FREE |
| **Local computer** | $0/month | Use your laptop |
| **Internet** | $0/month | Use existing connection |
| **Google Colab** | $0/month | FREE tier (or $10/month Pro) |
| **GitHub** | $0/month | Public repos FREE |
| **TOTAL** | **$0/month** | βœ… **100% FREE!** |

### Professional Approach (if scaling up)

| Component | Cost | Notes |
|-----------|------|-------|
| Hugging Face Pro | $9/month | Faster processing |
| Google Colab Pro | $10/month | More GPU time |
| AWS S3 (50 GB) | $1/month | Temporary storage |
| **TOTAL** | **$20/month** | Still very affordable |

---

## πŸŽ“ REAL EXAMPLE: MeetingBank Dataset

**Existing dataset on Hugging Face:**
- Name: `huuuyeah/meetingbank`
- Size: 1,366 meetings, 121 MB
- Cost: FREE
- Link: https://huggingface.co/datasets/huuuyeah/meetingbank

**You can do the same for oral health policy!**

```python
# Load existing MeetingBank data (FREE)
from datasets import load_dataset

meetingbank = load_dataset("huuuyeah/meetingbank")
print(f"Meetings: {len(meetingbank['train'])}")

# Create YOUR oral health dataset (also FREE!)
your_dataset = create_oral_health_dataset()
your_dataset.push_to_hub("your-username/oral-health-meetings")
```

---

## βœ… ACTION PLAN FOR YOU

### Week 1: Setup (Cost: $0)

1. βœ… Create Hugging Face account (FREE)
2. βœ… Get API token
3. βœ… Install libraries: `pip install huggingface_hub datasets`
4. βœ… Create dataset repo: `oral-health-policy-data`

### Week 2: Discovery (Cost: $0)

1. Run discovery pipeline for all 22,000 jurisdictions
2. Upload discovery results to Hugging Face (~1 GB)
3. Free up local storage

### Week 3-4: Content Processing (Cost: $0)

1. Process jurisdictions one at a time (streaming)
2. Extract text from PDFs
3. Filter for oral health keywords
4. Upload to Hugging Face
5. Delete local files immediately

**Local storage never exceeds 1 GB!**

### Ongoing: Analysis (Cost: $0)

1. Download relevant subset from Hugging Face
2. Analyze using Google Colab (FREE GPU)
3. Publish findings back to Hugging Face

---

## πŸ”‘ KEY PRINCIPLES

**1. Process, Don't Store**
- Download β†’ Process β†’ Upload β†’ Delete
- Never keep raw files locally

**2. Filter Early**
- Only save oral health-related content
- Discard irrelevant documents immediately

**3. Use Text, Not Files**
- Store extracted text (KB), not PDFs (MB)
- Link to original sources instead of duplicating

**4. Leverage Free Platforms**
- Hugging Face for datasets (FREE)
- Google Colab for processing (FREE)
- GitHub for code (FREE)

**5. Make It Public**
- Public datasets = unlimited FREE storage
- Helps other researchers
- Builds your portfolio

---

## πŸ“š ADDITIONAL FREE RESOURCES

### Processing Tools (FREE)

```bash
# PDF text extraction
pip install pypdf2 pdfplumber

# Document processing
pip install beautifulsoup4 lxml

# Data handling
pip install pandas pyarrow

# Upload to Hugging Face
pip install huggingface_hub datasets
```

### Computing (FREE)

1. **Google Colab** - FREE GPU/TPU
   - https://colab.research.google.com/
   - 15 GB RAM, 100 GB disk (temporary)

2. **Kaggle Notebooks** - FREE GPU
   - https://www.kaggle.com/code
   - 20 GB RAM, 73 GB disk (temporary)

3. **Hugging Face Spaces** - FREE hosting
   - https://huggingface.co/spaces
   - Run demos and apps

---

## 🎯 BOTTOM LINE

**YOU CAN DO THIS FOR $0/MONTH!**

βœ… **Storage:** Hugging Face (FREE, unlimited)  
βœ… **Processing:** Local computer or Google Colab (FREE)  
βœ… **Code:** GitHub (FREE)  
βœ… **Analysis:** Google Colab (FREE GPU)

**The entire 22,000-jurisdiction discovery and analysis can be done on a personal budget with ZERO cloud storage costs!**

---

## πŸ“ž NEXT STEPS

1. **Create Hugging Face account:** https://huggingface.co/join
2. **Create your dataset repo:** `oral-health-policy-data`
3. **Run discovery pipeline** (outputs ~1 GB locally)
4. **Upload to Hugging Face** (FREE unlimited storage)
5. **Process content streaming** (never store >100 MB locally)

**Questions?** Check Hugging Face docs: https://huggingface.co/docs/datasets/