import pandas as pd
import streamlit as st
from utils import *
backgroundPattern = """
"""
# backgroundPattern = """
#
# """
st.markdown(backgroundPattern, unsafe_allow_html=True)
st.write("""
# Resume Screening & Classification
""")
st.caption("""
Using K-Nearest Neighbors (KNN) algorithm and Cosine Similarity
######
""")
tab1, tab2, tab3 = st.tabs(['Getting Started', 'Classify', 'Rank'])
with tab1:
writeGettingStarted()
with tab2:
st.header('Input')
uploadedResumeClf = st.file_uploader('Upload Resumes', type = 'xlsx', key = 'upload-resume-clf')
if uploadedResumeClf is not None:
isButtonDisabledClf = False
else:
st.session_state.processClf = False
isButtonDisabledClf = True
if 'processClf' not in st.session_state:
st.session_state.processClf = False
st.button('Start Processing', on_click = clickClassify, disabled = isButtonDisabledClf, key = 'process-clf')
if st.session_state.processClf:
st.divider()
st.header('Output')
resumeClf = pd.read_excel(uploadedResumeClf)
resumeClf = classifyResumes(resumeClf)
with st.expander('View Bar Chart'):
barChart = createBarChart(resumeClf)
st.altair_chart(barChart, use_container_width = True)
currentClf = filterDataframeClf(resumeClf)
st.dataframe(currentClf, use_container_width = True, hide_index = True)
xlsxClf = convertDfToXlsx(currentClf)
st.download_button(label='Save Current Output as XLSX', data = xlsxClf, file_name = 'Resumes_categorized.xlsx')
with tab3:
st.header('Input')
uploadedJobDescriptionRnk = st.file_uploader('Upload Job Description', type = 'txt', key = 'upload-jd-rnk')
uploadedResumeRnk = st.file_uploader('Upload Resumes', type = 'xlsx', key = 'upload-resume-rnk')
if all([uploadedJobDescriptionRnk, uploadedResumeRnk]):
isButtonDisabledRnk = False
else:
st.session_state.processRank = False
isButtonDisabledRnk = True
if 'processRank' not in st.session_state:
st.session_state.processRank = False
st.button('Start Processing', on_click = clickRank, disabled = isButtonDisabledRnk, key = 'process-rnk')
if st.session_state.processRank:
st.divider()
st.header('Output')
jobDescriptionRnk = uploadedJobDescriptionRnk.read().decode('utf-8')
resumeRnk = pd.read_excel(uploadedResumeRnk)
resumeRnk = rankResumes(jobDescriptionRnk, resumeRnk)
with st.expander('View Job Description'):
st.write(jobDescriptionRnk)
currentRnk = filterDataframeRnk(resumeRnk)
st.dataframe(currentRnk, use_container_width = True, hide_index = True)
xlsxRnk = convertDfToXlsx(currentRnk)
st.download_button(label='Save Current Output as XLSX', data = xlsxRnk, file_name = 'Resumes_ranked.xlsx')