-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
77 lines (63 loc) · 2.26 KB
/
app.py
File metadata and controls
77 lines (63 loc) · 2.26 KB
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
import nltk
import pickle
import re
import streamlit as st
from sklearn.feature_extraction.text import TfidfVectorizer
tfidf = TfidfVectorizer(stop_words='english')
nltk.download('punkt')
nltk.download('stopwords')
clf = pickle.load(open('knn.pkl','rb'))
tfidf = pickle.load(open('tfidf.pkl','rb'))
# WEB APP
def cleanResume(txt):
cleanText = re.sub(r'http\S+\s', ' ', txt)
cleanText = re.sub(r'RT|cc', ' ', cleanText)
cleanText = re.sub(r'#\S+\s', ' ', cleanText)
cleanText = re.sub(r'@\S+', ' ', cleanText)
cleanText = re.sub(r'[%s]' % re.escape("""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""), ' ', cleanText)
cleanText = re.sub(r'[^\x00-\x7f]', ' ', cleanText)
cleanText = re.sub(r'\s+', ' ', cleanText)
return cleanText
def main():
st.title("Resume Screening App")
upload_file = st.file_uploader('Upload your resume',type=['txt','pdf'])
if upload_file is not None:
try:
resume_bytes = upload_file.read()
resume_text = resume_bytes.decode('utf-8')
except UnicodeDecodeError:
resume_text = resume_bytes.decode('latin-1')
cleaned_resume = cleanResume(resume_text)
tfidf_resume = tfidf.transform([cleaned_resume])
prediction_id = clf.predict(tfidf_resume)[0]
category_mapping = {
15: "Java Developer",
23: "Testing",
8: "DevOps Engineer",
20: "Python Developer",
24: "Web Designing",
12: "HR",
13: "Hadoop",
3: "Blockchain",
10: "ETL Developer",
18: "Operations Manager",
6: "Data Science",
22: "Sales",
16: "Mechanical Engineer",
1: "Arts",
7: "Database",
11: "Electrical Engineering",
14: "Health and fitness",
19: "PMO",
4: "Business Analyst",
9: "DotNet Developer",
2: "Automation Testing",
17: "Network Security Engineer",
21: "SAP Developer",
5: "Civil Engineer",
0: "Advocate",
}
category_name = category_mapping.get(prediction_id, "Unknown")
st.write("Predicted Category: ", category_name)
if __name__ == "__main__":
main()