CR7CAD commited on
Commit
0cda46e
·
verified ·
1 Parent(s): 546267f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -73
app.py CHANGED
@@ -671,91 +671,93 @@ def analyze_job_fit(resume_summary, job_description, models):
671
  models = load_models()
672
 
673
  #####################################
674
- # Main Streamlit Interface
675
  #####################################
676
- st.title("Resume-Job Fit Analyzer")
677
- st.markdown(
 
 
 
 
678
  """
679
- Upload your resume file in **.docx**, **.doc**, or **.txt** format and enter a job description to see how well you match with the job requirements.
680
- """
681
- )
682
 
683
- # Resume upload
684
- uploaded_file = st.file_uploader("Upload your resume (.docx, .doc, or .txt)", type=["docx", "doc", "txt"])
685
 
686
- # Job description input
687
- job_description = st.text_area("Enter Job Description", height=200, placeholder="Paste the job description here...")
688
 
689
- # Process button with optimized flow
690
- if uploaded_file is not None and job_description and st.button("Analyze Job Fit"):
691
- # Create a placeholder for the progress bar
692
- progress_bar = st.progress(0)
693
- status_text = st.empty()
694
-
695
- # Step 1: Extract text
696
- status_text.text("Step 1/3: Extracting text from resume...")
697
- resume_text = extract_text_from_file(uploaded_file)
698
- progress_bar.progress(25)
699
-
700
- if resume_text.startswith("Error") or resume_text == "Unsupported file type. Please upload a .docx, .doc, or .txt file.":
701
- st.error(resume_text)
702
- else:
703
- # Step 2: Generate summary
704
- status_text.text("Step 2/3: Analyzing resume and generating summary...")
705
- summary, summarization_time = summarize_resume_text(resume_text, models)
706
- progress_bar.progress(50)
707
 
708
- # Display summary
709
- st.subheader("Your Resume Summary")
710
- st.markdown(summary)
 
711
 
712
- # Step 3: Generate job fit assessment
713
- status_text.text("Step 3/3: Evaluating job fit (this will take a moment)...")
714
- assessment, fit_score, assessment_time = analyze_job_fit(summary, job_description, models)
715
- progress_bar.progress(100)
 
 
 
 
 
 
 
 
 
 
 
 
716
 
717
- # Clear status messages
718
- status_text.empty()
719
 
720
- # Display job fit results
721
- st.subheader("Job Fit Assessment")
722
 
723
- # Display fit score with label
724
- fit_labels = {
725
- 0: "NOT FIT",
726
- 1: "POTENTIAL FIT",
727
- 2: "GOOD FIT"
728
- }
729
-
730
- # Show the score prominently
731
- st.markdown(f"## {fit_labels[fit_score]}")
732
 
733
- # Display assessment
734
- st.markdown(assessment)
735
 
736
- st.info(f"Analysis completed in {(summarization_time + assessment_time):.2f} seconds")
737
-
738
- # Add potential next steps based on the fit score
739
- st.subheader("Recommended Next Steps")
740
-
741
- if fit_score == 2:
742
- st.markdown("""
743
- - Apply for this position as you appear to be a good match
744
- - Prepare for interviews by focusing on your relevant experience
745
- - Highlight your matching skills in your cover letter
746
- """)
747
- elif fit_score == 1:
748
- st.markdown("""
749
- - Consider applying but address skill gaps in your cover letter
750
- - Emphasize transferable skills and relevant experience
751
- - Prepare to discuss how you can quickly develop missing skills
752
- """)
753
- else:
754
- st.markdown("""
755
- - Look for positions better aligned with your current skills
756
- - If interested in this field, focus on developing the required skills
757
- - Consider similar roles with fewer experience requirements
758
- """)
759
 
760
  if __name__ == "__main__":
761
  main()
 
671
  models = load_models()
672
 
673
  #####################################
674
+ # Main Function
675
  #####################################
676
+ def main():
677
+ """Main function for the Streamlit application"""
678
+ st.title("Resume-Job Fit Analyzer")
679
+ st.markdown(
680
+ """
681
+ Upload your resume file in **.docx**, **.doc**, or **.txt** format and enter a job description to see how well you match with the job requirements.
682
  """
683
+ )
 
 
684
 
685
+ # Resume upload
686
+ uploaded_file = st.file_uploader("Upload your resume (.docx, .doc, or .txt)", type=["docx", "doc", "txt"])
687
 
688
+ # Job description input
689
+ job_description = st.text_area("Enter Job Description", height=200, placeholder="Paste the job description here...")
690
 
691
+ # Process button with optimized flow
692
+ if uploaded_file is not None and job_description and st.button("Analyze Job Fit"):
693
+ # Create a placeholder for the progress bar
694
+ progress_bar = st.progress(0)
695
+ status_text = st.empty()
 
 
 
 
 
 
 
 
 
 
 
 
 
696
 
697
+ # Step 1: Extract text
698
+ status_text.text("Step 1/3: Extracting text from resume...")
699
+ resume_text = extract_text_from_file(uploaded_file)
700
+ progress_bar.progress(25)
701
 
702
+ if resume_text.startswith("Error") or resume_text == "Unsupported file type. Please upload a .docx, .doc, or .txt file.":
703
+ st.error(resume_text)
704
+ else:
705
+ # Step 2: Generate summary
706
+ status_text.text("Step 2/3: Analyzing resume and generating summary...")
707
+ summary, summarization_time = summarize_resume_text(resume_text, models)
708
+ progress_bar.progress(50)
709
+
710
+ # Display summary
711
+ st.subheader("Your Resume Summary")
712
+ st.markdown(summary)
713
+
714
+ # Step 3: Generate job fit assessment
715
+ status_text.text("Step 3/3: Evaluating job fit (this will take a moment)...")
716
+ assessment, fit_score, assessment_time = analyze_job_fit(summary, job_description, models)
717
+ progress_bar.progress(100)
718
 
719
+ # Clear status messages
720
+ status_text.empty()
721
 
722
+ # Display job fit results
723
+ st.subheader("Job Fit Assessment")
724
 
725
+ # Display fit score with label
726
+ fit_labels = {
727
+ 0: "NOT FIT",
728
+ 1: "POTENTIAL FIT",
729
+ 2: "GOOD FIT"
730
+ }
731
+
732
+ # Show the score prominently
733
+ st.markdown(f"## {fit_labels[fit_score]}")
734
 
735
+ # Display assessment
736
+ st.markdown(assessment)
737
 
738
+ st.info(f"Analysis completed in {(summarization_time + assessment_time):.2f} seconds")
739
+
740
+ # Add potential next steps based on the fit score
741
+ st.subheader("Recommended Next Steps")
742
+
743
+ if fit_score == 2:
744
+ st.markdown("""
745
+ - Apply for this position as you appear to be a good match
746
+ - Prepare for interviews by focusing on your relevant experience
747
+ - Highlight your matching skills in your cover letter
748
+ """)
749
+ elif fit_score == 1:
750
+ st.markdown("""
751
+ - Consider applying but address skill gaps in your cover letter
752
+ - Emphasize transferable skills and relevant experience
753
+ - Prepare to discuss how you can quickly develop missing skills
754
+ """)
755
+ else:
756
+ st.markdown("""
757
+ - Look for positions better aligned with your current skills
758
+ - If interested in this field, focus on developing the required skills
759
+ - Consider similar roles with fewer experience requirements
760
+ """)
761
 
762
  if __name__ == "__main__":
763
  main()