Spaces:
Sleeping
Sleeping
Download src/loader.py from Vivek6041/ResearchMind: direct link, hf CLI and curl.
- Browser
- Download file 472 Bytes
-
https://huggingface.co/spaces/Vivek6041/ResearchMind/resolve/main/src/loader.py
- Command line
-
hf download hf://spaces/Vivek6041/ResearchMind/src/loader.py
-
curl -L -o loader.py https://huggingface.co/spaces/Vivek6041/ResearchMind/resolve/main/src/loader.py
472 Bytes
| import pymupdf4llm | |
| import re | |
| def load_pdf(file_path: str) -> str: | |
| md_text = pymupdf4llm.to_markdown(file_path) | |
| # remove picture blocks and HTML artifacts | |
| md_text = re.sub(r'\*\*----- Start of picture text -----\*\*.*?\*\*----- End of picture text -----\*\*', '', md_text, flags=re.DOTALL) | |
| md_text = re.sub(r'<br>', '\n', md_text) | |
| md_text = re.sub(r'==>.*?<==', '', md_text) | |
| md_text = re.sub(r'\n{3,}', '\n\n', md_text) | |
| return md_text |