File size: 3,781 Bytes
5bea701
 
5a5c182
c40c6c3
88d066d
040362f
5bea701
9ac410d
 
 
 
 
88d066d
 
9ac410d
23fd868
 
 
 
 
c71c13d
9c5c1b1
aa6c862
20bdb07
c71c13d
aa023ef
ffb9a11
aa023ef
319dddf
ffb9a11
20bdb07
 
c71c13d
 
 
 
 
 
 
20bdb07
 
 
6e78c7b
20bdb07
 
6e78c7b
20bdb07
 
23fd868
20bdb07
 
 
c71c13d
20bdb07
 
 
 
c71c13d
20bdb07
 
 
 
94d962f
 
394179b
9c5c1b1
 
 
aa6c862
9c5c1b1
 
ffb9a11
 
9c5c1b1
79bc629
c40c6c3
ffb9a11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c40c6c3
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
import streamlit as st
from PyPDF2 import PdfReader
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer

from sklearn.metrics.pairwise import cosine_similarity

import streamlit as st
from PyPDF2 import PdfReader
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
from gliner import GLiNER


import streamlit as st
import pandas as pd
from PyPDF2 import PdfReader
from gliner import GLiNER


txt = st.text_area("Job description", key = "text 1")
job_description_series = pd.Series(txt, name="Text")
st.dataframe(job_description_series)

uploaded_files = st.file_uploader(
    "Choose a PDF file(s) for candidate profiles",  type="pdf", key = "candidate 1"
)


all_resumes_text = []  # Store the text content of each PDF

if uploaded_files:
    for uploaded_file in uploaded_files:
        try:
            pdf_reader = PdfReader(uploaded_file)
            text_data = ""
            for page in pdf_reader.pages:
                text_data += page.extract_text()
            all_resumes_text.append(text_data)
        except Exception as e:
            st.error(f"Error processing file {uploaded_file.name}: {e}")

    if all_resumes_text:
        all_documents = [job_description_series.iloc[0]] + all_resumes_text

        vectorizer = TfidfVectorizer()
        tfidf_matrix = vectorizer.fit_transform(all_documents)

        tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
        st.subheader("TF-IDF Values:")
        st.dataframe(tfidf_df)

        cosine_sim_matrix = cosine_similarity(tfidf_matrix)
        cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
        st.subheader("Cosine Similarity Matrix:")
        st.dataframe(cosine_sim_df)

        # Display similarity scores between the job description and each resume
        st.subheader("Cosine Similarity Scores (Job Description vs. Resumes):")
        for i, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
            st.write(f"Similarity with Candidate Profile {i + 1}: {similarity_score:.4f}")


       
st.divider()

txt = st.text_area("Job description", key = "text 2")
job_description_series = pd.Series(txt, name="Text")
st.dataframe(job_description_series)

uploaded_files = st.file_uploader(
    "Choose a PDF file(s) for candidate profiles",  type="pdf", key = "candidate 2"
)


all_resumes_text = []  # Store the text content of each PDF

if uploaded_files:
    for uploaded_file in uploaded_files:
        try:
            pdf_reader = PdfReader(uploaded_file)
            text_data = ""
            for page in pdf_reader.pages:
                text_data += page.extract_text()
            all_resumes_text.append(text_data)
        except Exception as e:
            st.error(f"Error processing file {uploaded_file.name}: {e}")

    if all_resumes_text:
        all_documents = [job_description_series.iloc[0]] + all_resumes_text

        vectorizer = TfidfVectorizer()
        tfidf_matrix = vectorizer.fit_transform(all_documents)

        tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
        st.subheader("TF-IDF Values:")
        st.dataframe(tfidf_df)

        cosine_sim_matrix = cosine_similarity(tfidf_matrix)
        cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
        st.subheader("Cosine Similarity Matrix:")
        st.dataframe(cosine_sim_df)

        # Display similarity scores between the job description and each resume
        st.subheader("Cosine Similarity Scores (Job Description vs. Resumes):")
        for i, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
            st.write(f"Similarity with Candidate Profile {i + 1}: {similarity_score:.4f}")