Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,10 +18,13 @@ def setup_chromadb():
|
|
| 18 |
|
| 19 |
def extract_text_from_resume(file):
|
| 20 |
if file.name.endswith(".pdf"):
|
| 21 |
-
|
|
|
|
| 22 |
return "\n".join([page.get_text("text") for page in doc])
|
| 23 |
elif file.name.endswith(".txt"):
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
return ""
|
| 26 |
|
| 27 |
def extract_candidate_name(resume_text):
|
|
|
|
| 18 |
|
| 19 |
def extract_text_from_resume(file):
|
| 20 |
if file.name.endswith(".pdf"):
|
| 21 |
+
# For PDF files, read the bytes directly
|
| 22 |
+
with fitz.open(stream=file, filetype="pdf") as doc:
|
| 23 |
return "\n".join([page.get_text("text") for page in doc])
|
| 24 |
elif file.name.endswith(".txt"):
|
| 25 |
+
# For text files, read as string
|
| 26 |
+
with open(file.name, "r", encoding="utf-8") as f:
|
| 27 |
+
return f.read()
|
| 28 |
return ""
|
| 29 |
|
| 30 |
def extract_candidate_name(resume_text):
|