| from pathlib import Path | |
| def read_job_description(path: str | Path) -> str: | |
| path = Path(path) | |
| suffix = path.suffix.lower() | |
| if suffix == ".txt": | |
| return path.read_text(encoding="utf-8") | |
| if suffix == ".docx": | |
| from docx import Document | |
| document = Document(path) | |
| paragraphs = [paragraph.text.strip() for paragraph in document.paragraphs if paragraph.text.strip()] | |
| return "\n".join(paragraphs) | |
| raise ValueError(f"Unsupported job description format: {path.suffix}") | |