Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pickle
|
| 3 |
+
import re
|
| 4 |
+
import nltk
|
| 5 |
+
from pypdf import PdfReader
|
| 6 |
+
|
| 7 |
+
nltk.download('punkt')
|
| 8 |
+
nltk.download('stopwords')
|
| 9 |
+
|
| 10 |
+
model = pickle.load(open('model.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 |
+
return clean_text
|
| 20 |
+
def main():
|
| 21 |
+
st.title("Resume Screening App")
|
| 22 |
+
uploaded_file = st.file_uploader('Upload Your Resume Here', type=['txt','pdf'])
|
| 23 |
+
|
| 24 |
+
if uploaded_file is not None:
|
| 25 |
+
try:
|
| 26 |
+
reader = PdfReader(uploaded_file)
|
| 27 |
+
page = reader.pages[0]
|
| 28 |
+
text = page.extract_text()
|
| 29 |
+
except :
|
| 30 |
+
st.write("sorry file cannot be read")
|
| 31 |
+
|
| 32 |
+
cleaned_resume = clean_resume(text)
|
| 33 |
+
input_features = tfidfd.transform([cleaned_resume])
|
| 34 |
+
prediction_id = model.predict(input_features)[0]
|
| 35 |
+
|
| 36 |
+
# Map category ID to category name
|
| 37 |
+
category_mapping = {
|
| 38 |
+
15: "Java Developer",
|
| 39 |
+
23: "Testing",
|
| 40 |
+
8: "DevOps Engineer",
|
| 41 |
+
20: "Python Developer",
|
| 42 |
+
24: "Web Designing",
|
| 43 |
+
12: "HR",
|
| 44 |
+
13: "Hadoop",
|
| 45 |
+
3: "Blockchain",
|
| 46 |
+
10: "ETL Developer",
|
| 47 |
+
18: "Operations Manager",
|
| 48 |
+
6: "Data Science",
|
| 49 |
+
22: "Sales",
|
| 50 |
+
16: "Mechanical Engineer",
|
| 51 |
+
1: "Arts",
|
| 52 |
+
7: "Database",
|
| 53 |
+
11: "Electrical Engineering",
|
| 54 |
+
14: "Health and fitness",
|
| 55 |
+
19: "PMO",
|
| 56 |
+
4: "Business Analyst",
|
| 57 |
+
9: "DotNet Developer",
|
| 58 |
+
2: "Automation Testing",
|
| 59 |
+
17: "Network Security Engineer",
|
| 60 |
+
21: "SAP Developer",
|
| 61 |
+
5: "Civil Engineer",
|
| 62 |
+
0: "Advocate",
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
category_name = category_mapping.get(prediction_id)
|
| 66 |
+
st.write("The Predicted Category for your Resume is :", category_name)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
# python main
|
| 71 |
+
if __name__ == "__main__":
|
| 72 |
+
main()
|