-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.py
More file actions
141 lines (90 loc) Β· 3.02 KB
/
Copy pathapplication.py
File metadata and controls
141 lines (90 loc) Β· 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import sys
import streamlit as st
import pdfplumber
from Resume_scanner import compare
def extract_pdf_data(file):
data = ""
with pdfplumber.open(file) as pdf:
for page in pdf.pages:
text = page.extract_text()
if text:
data += text
return data
def extract_text_data(file_path):
with open(file_path, "r", encoding="utf-8") as file:
return file.read()
# Command-line argument processing
if len(sys.argv) > 1:
if len(sys.argv) == 3:
resume_path = sys.argv[1]
jd_path = sys.argv[2]
resume_data = extract_pdf_data(resume_path)
jd_data = extract_text_data(jd_path)
compare([resume_data], jd_data, flag="HuggingFace-BERT")
sys.exit()
# ---------------- Sidebar ---------------- #
st.set_page_config(page_title="Applicant Tracking System", page_icon="π")
flag = "HuggingFace-BERT"
with st.sidebar:
st.title("Settings")
flag = st.selectbox(
"Embedding Model",
["HuggingFace-BERT", "Doc2Vec"]
)
# ---------------- Tabs ---------------- #
tab1, tab2 = st.tabs(["Home", "π Results"])
# Variables to avoid NameError
score = []
uploaded_files = []
comp_pressed = False
# ---------------- Home ---------------- #
with tab1:
st.title("π Applicant Tracking System")
uploaded_files = st.file_uploader(
"Upload Resume(s) (PDF)",
type="pdf",
accept_multiple_files=True
)
JD = st.text_area(
"Enter Job Description",
height=200
)
comp_pressed = st.button("Compare")
if comp_pressed:
if not uploaded_files:
st.error("Please upload at least one resume.")
elif JD.strip() == "":
st.error("Please enter a job description.")
else:
with st.spinner("Comparing resumes..."):
resume_texts = [
extract_pdf_data(file)
for file in uploaded_files
]
score = compare(
resume_texts,
JD,
flag
)
st.success("Comparison completed successfully!")
st.info("Click the **Results** tab to view the ATS score.")
# ---------------- Results ---------------- #
with tab2:
st.header("π ATS Results")
if comp_pressed and score:
for i in range(len(score)):
score_value = float(score[i])
with st.expander(uploaded_files[i].name, expanded=True):
st.metric(
label="ATS Match Score",
value=f"{score_value:.2f}%"
)
st.progress(min(int(score_value), 100))
if score_value >= 80:
st.success("Excellent Match β
")
elif score_value >= 60:
st.warning("Good Match π")
else:
st.error("Needs Improvement β")
else:
st.info("Upload a resume and click Compare to view results.")