Spaces:
No application file
No application file
Create Src/app.py
Browse files- Src/app.py +56 -0
Src/app.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from pdf_parser import parse_resume
|
| 3 |
+
|
| 4 |
+
st.set_page_config(page_title="Resume Parser", layout="centered")
|
| 5 |
+
st.title("Resume Parser")
|
| 6 |
+
|
| 7 |
+
uploaded_file = st.file_uploader("Upload your resume (PDF)", type=["pdf"])
|
| 8 |
+
if uploaded_file:
|
| 9 |
+
with open("temp_resume.pdf", "wb") as f:
|
| 10 |
+
f.write(uploaded_file.getbuffer())
|
| 11 |
+
|
| 12 |
+
try:
|
| 13 |
+
result = parse_resume("temp_resume.pdf")
|
| 14 |
+
except Exception as e:
|
| 15 |
+
st.error(f"Error parsing resume: {str(e)}")
|
| 16 |
+
st.stop()
|
| 17 |
+
|
| 18 |
+
# Prepare structured output
|
| 19 |
+
structured_output = {
|
| 20 |
+
"name": result.get("name", {}).get("value"),
|
| 21 |
+
"email": result.get("email", {}).get("value"),
|
| 22 |
+
"phone": result.get("phone", {}).get("value"),
|
| 23 |
+
"linkedin": result.get("linkedin", {}).get("value"),
|
| 24 |
+
"skills": result.get("skills", {}).get("value") or [],
|
| 25 |
+
"education": result.get("education", {}).get("value"),
|
| 26 |
+
"experience": result.get("experience", {}).get("value"),
|
| 27 |
+
"projects": result.get("projects", {}).get("value"),
|
| 28 |
+
"certifications": result.get("certifications", {}).get("value"),
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
# Display results
|
| 32 |
+
st.subheader("Parsed Resume Data")
|
| 33 |
+
st.json(structured_output)
|
| 34 |
+
|
| 35 |
+
st.subheader("Detailed Analysis")
|
| 36 |
+
fields = [
|
| 37 |
+
("Personal Info", ["name", "email", "phone", "linkedin"]),
|
| 38 |
+
("Skills", ["skills"]),
|
| 39 |
+
("Professional History", ["experience", "projects"]),
|
| 40 |
+
("Education & Certifications", ["education", "certifications"])
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
for category, field_keys in fields:
|
| 44 |
+
st.markdown(f"### {category}")
|
| 45 |
+
cols = st.columns(2)
|
| 46 |
+
for i, field in enumerate(field_keys):
|
| 47 |
+
data = result.get(field, {})
|
| 48 |
+
value = data.get("value", "NIL")
|
| 49 |
+
conf = data.get("confidence", 0)
|
| 50 |
+
|
| 51 |
+
if value == "NIL" or conf == 0:
|
| 52 |
+
cols[i%2].error(f"{field.title()}: Not detected")
|
| 53 |
+
elif conf < 0.7:
|
| 54 |
+
cols[i%2].warning(f"{field.title()}: {value} (Confidence: {conf:.0%})")
|
| 55 |
+
else:
|
| 56 |
+
cols[i%2].success(f"{field.title()}: {value} (Confidence: {conf:.0%})")
|