Spaces:
Sleeping
Sleeping
Download utils/loader.py from anusha1840/HackRx: direct link, hf CLI and curl.
- Browser
- Download file 375 Bytes
-
https://huggingface.co/spaces/anusha1840/HackRx/resolve/main/utils/loader.py
- Command line
-
hf download hf://spaces/anusha1840/HackRx/utils/loader.py
-
curl -L -o loader.py https://huggingface.co/spaces/anusha1840/HackRx/resolve/main/utils/loader.py
375 Bytes
| import fitz # PyMuPDF | |
| def extract_text_from_pdf(pdf_path: str) -> str: | |
| text = "" | |
| try: | |
| with fitz.open(pdf_path) as doc: | |
| for page in doc: | |
| text += page.get_text() | |
| return text.replace("\n", " ").replace(" ", " ").strip() | |
| except Exception as e: | |
| print(f"PDF Extraction Error: {e}") | |
| return "" | |