Spaces:
Runtime error
Runtime error
| import pdfplumber | |
| def extract_text_from_pdf(pdf_path: str) -> str: | |
| """Extract text from PDF file""" | |
| try: | |
| with pdfplumber.open(pdf_path) as pdf: | |
| text = "\n".join([ | |
| page.extract_text() or "" | |
| for page in pdf.pages | |
| ]) | |
| return text.strip() | |
| except Exception as e: | |
| print(f"❌ PDF extraction error: {str(e)}") | |
| return "" | |
| def extract_section(text: str, keywords: list) -> str: | |
| """ | |
| Extract section from resume based on keywords | |
| Returns first 1500 chars of section or beginning of text | |
| """ | |
| text_lower = text.lower() | |
| for key in keywords: | |
| if key in text_lower: | |
| idx = text_lower.find(key) | |
| return text[idx:idx+1500] | |
| return text[:1500] | |