Update app.py
Browse files
app.py
CHANGED
@@ -1,77 +1,77 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import pickle
|
3 |
-
import re
|
4 |
-
import nltk
|
5 |
-
|
6 |
-
nltk.download('punkt')
|
7 |
-
nltk.download('stopwords')
|
8 |
-
|
9 |
-
#loading models
|
10 |
-
clf = pickle.load(open('clf.pkl','rb'))
|
11 |
-
tfidfd = pickle.load(open('tfidf.pkl','rb'))
|
12 |
-
|
13 |
-
def clean_resume(resume_text):
|
14 |
-
clean_text = re.sub('http\S+\s*', ' ', resume_text)
|
15 |
-
clean_text = re.sub('RT|cc', ' ', clean_text)
|
16 |
-
clean_text = re.sub('#\S+', '', clean_text)
|
17 |
-
clean_text = re.sub('@\S+', ' ', clean_text)
|
18 |
-
clean_text = re.sub('[%s]' % re.escape("""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""), ' ', clean_text)
|
19 |
-
clean_text = re.sub(r'[^\x00-\x7f]', r' ', clean_text)
|
20 |
-
clean_text = re.sub('\s+', ' ', clean_text)
|
21 |
-
return clean_text
|
22 |
-
# web app
|
23 |
-
def main():
|
24 |
-
st.title("Resume Screening App")
|
25 |
-
uploaded_file = st.file_uploader('Upload Resume', type=['txt','pdf'])
|
26 |
-
|
27 |
-
if uploaded_file is not None:
|
28 |
-
try:
|
29 |
-
resume_bytes = uploaded_file.read()
|
30 |
-
resume_text = resume_bytes.decode('utf-8')
|
31 |
-
except UnicodeDecodeError:
|
32 |
-
# If UTF-8 decoding fails, try decoding with 'latin-1'
|
33 |
-
resume_text = resume_bytes.decode('latin-1')
|
34 |
-
|
35 |
-
cleaned_resume = clean_resume(resume_text)
|
36 |
-
input_features = tfidfd.transform([cleaned_resume])
|
37 |
-
prediction_id = clf.predict(input_features)[0]
|
38 |
-
st.write(prediction_id)
|
39 |
-
|
40 |
-
# Map category ID to category name
|
41 |
-
category_mapping = {
|
42 |
-
15: "Java Developer",
|
43 |
-
23: "Testing",
|
44 |
-
8: "
|
45 |
-
20: "Python Developer",
|
46 |
-
24: "Web Designing",
|
47 |
-
12: "HR",
|
48 |
-
13: "Hadoop",
|
49 |
-
3: "Blockchain",
|
50 |
-
10: "ETL Developer",
|
51 |
-
18: "Operations Manager",
|
52 |
-
6: "Data Science",
|
53 |
-
22: "Sales",
|
54 |
-
16: "Mechanical Engineer",
|
55 |
-
1: "Arts",
|
56 |
-
7: "Database",
|
57 |
-
11: "Electrical Engineering",
|
58 |
-
14: "Health and fitness",
|
59 |
-
19: "PMO",
|
60 |
-
4: "Business Analyst",
|
61 |
-
9: "DotNet Developer",
|
62 |
-
2: "Automation Testing",
|
63 |
-
17: "Network Security Engineer",
|
64 |
-
21: "SAP Developer",
|
65 |
-
5: "Civil Engineer",
|
66 |
-
0: "Advocate",
|
67 |
-
}
|
68 |
-
|
69 |
-
category_name = category_mapping.get(prediction_id, "Unknown")
|
70 |
-
|
71 |
-
st.write("Predicted Category:", category_name)
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
# python main
|
76 |
-
if __name__ == "__main__":
|
77 |
-
main()
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pickle
|
3 |
+
import re
|
4 |
+
import nltk
|
5 |
+
|
6 |
+
nltk.download('punkt')
|
7 |
+
nltk.download('stopwords')
|
8 |
+
|
9 |
+
#loading models
|
10 |
+
clf = pickle.load(open('clf.pkl','rb'))
|
11 |
+
tfidfd = pickle.load(open('tfidf.pkl','rb'))
|
12 |
+
|
13 |
+
def clean_resume(resume_text):
|
14 |
+
clean_text = re.sub('http\S+\s*', ' ', resume_text)
|
15 |
+
clean_text = re.sub('RT|cc', ' ', clean_text)
|
16 |
+
clean_text = re.sub('#\S+', '', clean_text)
|
17 |
+
clean_text = re.sub('@\S+', ' ', clean_text)
|
18 |
+
clean_text = re.sub('[%s]' % re.escape("""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""), ' ', clean_text)
|
19 |
+
clean_text = re.sub(r'[^\x00-\x7f]', r' ', clean_text)
|
20 |
+
clean_text = re.sub('\s+', ' ', clean_text)
|
21 |
+
return clean_text
|
22 |
+
# web app
|
23 |
+
def main():
|
24 |
+
st.title("Resume Screening App")
|
25 |
+
uploaded_file = st.file_uploader('Upload Resume', type=['txt','pdf'])
|
26 |
+
|
27 |
+
if uploaded_file is not None:
|
28 |
+
try:
|
29 |
+
resume_bytes = uploaded_file.read()
|
30 |
+
resume_text = resume_bytes.decode('utf-8')
|
31 |
+
except UnicodeDecodeError:
|
32 |
+
# If UTF-8 decoding fails, try decoding with 'latin-1'
|
33 |
+
resume_text = resume_bytes.decode('latin-1')
|
34 |
+
|
35 |
+
cleaned_resume = clean_resume(resume_text)
|
36 |
+
input_features = tfidfd.transform([cleaned_resume])
|
37 |
+
prediction_id = clf.predict(input_features)[0]
|
38 |
+
st.write(prediction_id)
|
39 |
+
|
40 |
+
# Map category ID to category name
|
41 |
+
category_mapping = {
|
42 |
+
15: "Java Developer",
|
43 |
+
23: "Testing",
|
44 |
+
8: "AI/ML Engineer",
|
45 |
+
20: "Python Developer",
|
46 |
+
24: "Web Designing",
|
47 |
+
12: "HR",
|
48 |
+
13: "Hadoop",
|
49 |
+
3: "Blockchain",
|
50 |
+
10: "ETL Developer",
|
51 |
+
18: "Operations Manager",
|
52 |
+
6: "Data Science",
|
53 |
+
22: "Sales",
|
54 |
+
16: "Mechanical Engineer",
|
55 |
+
1: "Arts",
|
56 |
+
7: "Database",
|
57 |
+
11: "Electrical Engineering",
|
58 |
+
14: "Health and fitness",
|
59 |
+
19: "PMO",
|
60 |
+
4: "Business Analyst",
|
61 |
+
9: "DotNet Developer",
|
62 |
+
2: "Automation Testing",
|
63 |
+
17: "Network Security Engineer",
|
64 |
+
21: "SAP Developer",
|
65 |
+
5: "Civil Engineer",
|
66 |
+
0: "Advocate",
|
67 |
+
}
|
68 |
+
|
69 |
+
category_name = category_mapping.get(prediction_id, "Unknown")
|
70 |
+
|
71 |
+
st.write("Predicted Category:", category_name)
|
72 |
+
|
73 |
+
|
74 |
+
|
75 |
+
# python main
|
76 |
+
if __name__ == "__main__":
|
77 |
+
main()
|