Upload 2 files
Browse files- requirements.txt +4 -0
- resume.py +46 -0
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
spacy
|
3 |
+
PyPDF2
|
4 |
+
python-docx
|
resume.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import PyPDF2
|
3 |
+
import docx
|
4 |
+
import spacy
|
5 |
+
|
6 |
+
# Load NLP model
|
7 |
+
@st.cache_resource
|
8 |
+
def load_model():
|
9 |
+
return spacy.load("en_core_web_sm")
|
10 |
+
|
11 |
+
nlp = load_model()
|
12 |
+
|
13 |
+
# Function to extract text
|
14 |
+
def extract_text(file):
|
15 |
+
if file.type == "application/pdf":
|
16 |
+
reader = PyPDF2.PdfFileReader(file)
|
17 |
+
return "".join([reader.getPage(i).extract_text() for i in range(reader.numPages)])
|
18 |
+
elif file.type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
19 |
+
return "\n".join([para.text for para in docx.Document(file).paragraphs])
|
20 |
+
|
21 |
+
# Function to extract and display information
|
22 |
+
def analyze_resume(text, job_desc):
|
23 |
+
doc = nlp(text)
|
24 |
+
extracted_info = {"skills": [], "education": [], "experience": []}
|
25 |
+
|
26 |
+
for ent in doc.ents:
|
27 |
+
if ent.label_ in ["ORG", "GPE"]:
|
28 |
+
extracted_info["education"].append(ent.text)
|
29 |
+
elif ent.label_ == "DATE":
|
30 |
+
extracted_info["experience"].append(ent.text)
|
31 |
+
|
32 |
+
match_score = sum(1 for token in nlp(job_desc) if token.text in text) / len(job_desc.split()) * 100
|
33 |
+
return extracted_info, match_score
|
34 |
+
|
35 |
+
# Streamlit interface
|
36 |
+
st.title("Resume Scanner with NLP")
|
37 |
+
uploaded_file = st.file_uploader("Upload a resume (PDF or DOCX)", type=["pdf", "docx"])
|
38 |
+
job_description = st.text_area("Paste the job description here")
|
39 |
+
|
40 |
+
if uploaded_file and job_description:
|
41 |
+
resume_text = extract_text(uploaded_file)
|
42 |
+
extracted_info, match_score = analyze_resume(resume_text, job_description)
|
43 |
+
|
44 |
+
st.subheader("Extracted Information:")
|
45 |
+
st.write(extracted_info)
|
46 |
+
st.subheader(f"Match Score: {match_score:.2f}%")
|