Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,13 +17,16 @@ def setup_chromadb():
|
|
| 17 |
return client.get_or_create_collection(name="resumes")
|
| 18 |
|
| 19 |
def extract_text_from_resume(file):
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
| 23 |
return "\n".join([page.get_text("text") for page in doc])
|
| 24 |
-
elif
|
| 25 |
-
#
|
| 26 |
-
with open(
|
| 27 |
return f.read()
|
| 28 |
return ""
|
| 29 |
|
|
|
|
| 17 |
return client.get_or_create_collection(name="resumes")
|
| 18 |
|
| 19 |
def extract_text_from_resume(file):
|
| 20 |
+
# Get the file path from Gradio's file object
|
| 21 |
+
file_path = file.name
|
| 22 |
+
|
| 23 |
+
if file_path.endswith(".pdf"):
|
| 24 |
+
# Open the PDF file directly from the path
|
| 25 |
+
with fitz.open(file_path) as doc:
|
| 26 |
return "\n".join([page.get_text("text") for page in doc])
|
| 27 |
+
elif file_path.endswith(".txt"):
|
| 28 |
+
# Open the text file directly
|
| 29 |
+
with open(file_path, "r", encoding="utf-8") as f:
|
| 30 |
return f.read()
|
| 31 |
return ""
|
| 32 |
|