nlpblogs commited on
Commit
ffb9a11
·
verified ·
1 Parent(s): 20bdb07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -2
app.py CHANGED
@@ -24,9 +24,10 @@ job_description_series = pd.Series([txt], name="Text")
24
  st.dataframe(job_description_series)
25
 
26
  uploaded_files = st.file_uploader(
27
- "Choose a PDF file(s) for candidate profiles", accept_multiple_files=True, type="pdf"
28
  )
29
 
 
30
  all_resumes_text = [] # Store the text content of each PDF
31
 
32
  if uploaded_files:
@@ -62,9 +63,44 @@ if uploaded_files:
62
 
63
 
64
 
65
-
 
 
66
 
67
 
68
 
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
 
24
  st.dataframe(job_description_series)
25
 
26
  uploaded_files = st.file_uploader(
27
+ "Choose a PDF file(s) for candidate profiles", type="pdf", key = "candidate 1"
28
  )
29
 
30
+
31
  all_resumes_text = [] # Store the text content of each PDF
32
 
33
  if uploaded_files:
 
63
 
64
 
65
 
66
+ uploaded_files = st.file_uploader(
67
+ "Choose a PDF file(s) for candidate profiles", type="pdf", key = "candidate 2"
68
+ )
69
 
70
 
71
 
72
 
73
+ all_resumes_text = [] # Store the text content of each PDF
74
+
75
+ if uploaded_files:
76
+ for uploaded_file in uploaded_files:
77
+ try:
78
+ pdf_reader = PdfReader(uploaded_file)
79
+ text_data = ""
80
+ for page in pdf_reader.pages:
81
+ text_data += page.extract_text()
82
+ all_resumes_text.append(text_data)
83
+ except Exception as e:
84
+ st.error(f"Error processing file {uploaded_file.name}: {e}")
85
+
86
+ if all_resumes_text:
87
+ all_documents = [job_description_series.iloc[0]] + all_resumes_text
88
+
89
+ vectorizer = TfidfVectorizer()
90
+ tfidf_matrix = vectorizer.fit_transform(all_documents)
91
+
92
+ tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
93
+ st.subheader("TF-IDF Values:")
94
+ st.dataframe(tfidf_df)
95
+
96
+ cosine_sim_matrix = cosine_similarity(tfidf_matrix)
97
+ cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
98
+ st.subheader("Cosine Similarity Matrix:")
99
+ st.dataframe(cosine_sim_df)
100
+
101
+ # Display similarity scores between the job description and each resume
102
+ st.subheader("Cosine Similarity Scores (Job Description vs. Resumes):")
103
+ for i, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
104
+ st.write(f"Similarity with Candidate Profile {i + 1}: {similarity_score:.4f}")
105
+
106