Download src/document_processing/extractors.py from Estarcode/campusdesk-ai: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/Estarcode/campusdesk-ai/resolve/main/src/document_processing/extractors.py
- Command line
-
hf download hf://Estarcode/campusdesk-ai/src/document_processing/extractors.py
-
curl -L -o extractors.py https://huggingface.co/Estarcode/campusdesk-ai/resolve/main/src/document_processing/extractors.py
1 kB
| """Raw document extractors for institutional PDF notices and CSV schedules.""" | |
| import csv | |
| from pathlib import Path | |
| from typing import Dict, List | |
| import pandas as pd | |
| import pymupdf | |
| from src.config import ROOT_DIR, SOURCE_MANIFEST_PATH | |
| def load_manifest_rows(manifest_path: Path = SOURCE_MANIFEST_PATH) -> List[Dict[str, str]]: | |
| """Load source provenance rows from source_manifest.csv.""" | |
| with manifest_path.open("r", encoding="utf-8", newline="") as f: | |
| return list(csv.DictReader(f)) | |
| def extract_pdf_text(file_path: str) -> str: | |
| """Extract raw text from all pages of a PDF notice.""" | |
| pdf_path = ROOT_DIR / file_path | |
| doc = pymupdf.open(pdf_path) | |
| text = "\n".join(page.get_text("text") for page in doc) | |
| doc.close() | |
| return text | |
| def extract_csv_rows(file_path: str) -> List[Dict[str, str]]: | |
| """Read structured fee/tier schedule rows from CSV.""" | |
| csv_path = ROOT_DIR / file_path | |
| df = pd.read_csv(csv_path) | |
| return df.to_dict(orient="records") | |