Spaces:
Sleeping
Sleeping
Download data.py from ArthurLin/resume_recommendation_LLM: direct link, hf CLI and curl.
- Browser
- Download file 536 Bytes
-
https://huggingface.co/spaces/ArthurLin/resume_recommendation_LLM/resolve/main/data.py
- Command line
-
hf download hf://spaces/ArthurLin/resume_recommendation_LLM/data.py
-
curl -L -o data.py https://huggingface.co/spaces/ArthurLin/resume_recommendation_LLM/resolve/main/data.py
536 Bytes
| import os | |
| import fitz # PyMuPDF | |
| def load_text(path): | |
| file_extension = os.path.splitext(path)[1].lower() | |
| if file_extension == ".pdf": | |
| doc = fitz.open(path) | |
| texts = [] | |
| for page in doc: | |
| texts.append(page.get_text()) | |
| return "\n".join(texts) | |
| elif file_extension == ".txt": | |
| with open(path, "r", encoding="utf-8") as file: | |
| return file.read() | |
| else: | |
| raise ValueError(f"Unsupported file type: {file_extension}. Only PDF and TXT are supported.") | |