-
Notifications
You must be signed in to change notification settings - Fork 7
/
application.py
72 lines (58 loc) · 2.02 KB
/
application.py
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
import sys
import streamlit as st
import pdfplumber
from Resume_scanner import compare
def extract_pdf_data(file_path):
data = ""
with pdfplumber.open(file_path) 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') as file:
data = file.read()
return data
# 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)
result = compare([resume_data], jd_data, flag='HuggingFace-BERT')
sys.exit()
# Sidebar
flag = 'HuggingFace-BERT'
with st.sidebar:
st.markdown('**Which embedding do you want to use**')
options = st.selectbox('Which embedding do you want to use',
['HuggingFace-BERT', 'Doc2Vec'],
label_visibility="collapsed")
flag = options
# Main content
tab1, tab2 = st.tabs(["**Home**", "**Results**"])
# Tab Home
with tab1:
st.title("Applicant Tracking System")
uploaded_files = st.file_uploader(
'**Choose your resume.pdf file:** ', type="pdf", accept_multiple_files=True)
JD = st.text_area("**Enter the job description:**")
comp_pressed = st.button("Compare!")
if comp_pressed and uploaded_files:
# Streamlit file_uploader gives file-like objects, not paths
uploaded_file_paths = [extract_pdf_data(
file) for file in uploaded_files]
score = compare(uploaded_file_paths, JD, flag)
# Tab Results
with tab2:
st.header("Results")
my_dict = {}
if comp_pressed and uploaded_files:
for i in range(len(score)):
my_dict[uploaded_files[i].name] = score[i]
sorted_dict = dict(sorted(my_dict.items()))
for i in sorted_dict.items():
with st.expander(str(i[0])):
st.write("Score is: ", i[1])