Upload app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,6 @@ from tensorflow.keras.models import load_model
|
|
| 8 |
from tensorflow.keras.preprocessing.sequence import pad_sequences
|
| 9 |
import os
|
| 10 |
|
| 11 |
-
# Abbreviations dictionary for job market
|
| 12 |
abbreviations = {
|
| 13 |
"mgr": "manager",
|
| 14 |
"sr": "senior",
|
|
@@ -135,53 +134,90 @@ def extract_nouns(text):
|
|
| 135 |
nouns = [token.lemma_ for token in doc if token.pos_ == "NOUN"]
|
| 136 |
return nouns
|
| 137 |
|
| 138 |
-
def
|
| 139 |
-
model_path =
|
| 140 |
-
tokenizer_path =
|
| 141 |
-
|
| 142 |
if not os.path.isfile(model_path):
|
| 143 |
raise FileNotFoundError(f"Model file not found: {model_path}")
|
| 144 |
-
|
| 145 |
if not os.path.isfile(tokenizer_path):
|
| 146 |
raise FileNotFoundError(f"Tokenizer file not found: {tokenizer_path}")
|
| 147 |
-
|
| 148 |
model = load_model(model_path)
|
| 149 |
-
|
| 150 |
with open(tokenizer_path, 'rb') as f:
|
| 151 |
tokenizers = pickle.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
resume_tokenizer = tokenizers.get('resume_tokenizer')
|
| 154 |
description_tokenizer = tokenizers.get('description_tokenizer')
|
| 155 |
common_nouns_tokenizer = tokenizers.get('common_nouns_tokenizer')
|
|
|
|
|
|
|
|
|
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
if not (resume_tokenizer and description_tokenizer and common_nouns_tokenizer):
|
| 158 |
raise ValueError("Tokenizer components are missing from the file.")
|
|
|
|
| 159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
return model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer
|
| 161 |
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
'
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
'
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
'tokenizer': r'tokernizer\tokenizershealth.pkl'
|
| 179 |
-
},
|
| 180 |
-
'Other': {
|
| 181 |
-
'model': r'modelfile\bigothers2.keras',
|
| 182 |
-
'tokenizer': r'tokernizer\tokenizersothers.pkl'
|
| 183 |
-
}
|
| 184 |
-
}
|
| 185 |
|
| 186 |
# Streamlit UI
|
| 187 |
st.title("ATS")
|
|
@@ -195,12 +231,21 @@ resume = st.text_area("Paste your Resume:", height=150)
|
|
| 195 |
job_description = st.text_area("Paste Job Description:", height=150)
|
| 196 |
|
| 197 |
# Sector selection
|
| 198 |
-
sector = st.selectbox("Select Sector:",
|
| 199 |
|
| 200 |
if st.button("Calculate ATS Score"):
|
| 201 |
if resume and job_description:
|
| 202 |
try:
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
|
| 205 |
processed_resume = clean_and_preprocess(resume)
|
| 206 |
processed_description = clean_and_preprocess(job_description)
|
|
|
|
| 8 |
from tensorflow.keras.preprocessing.sequence import pad_sequences
|
| 9 |
import os
|
| 10 |
|
|
|
|
| 11 |
abbreviations = {
|
| 12 |
"mgr": "manager",
|
| 13 |
"sr": "senior",
|
|
|
|
| 134 |
nouns = [token.lemma_ for token in doc if token.pos_ == "NOUN"]
|
| 135 |
return nouns
|
| 136 |
|
| 137 |
+
def load_model_and_tokenizers_for_hr():
|
| 138 |
+
model_path = 'modelfile/bighr2.keras'
|
| 139 |
+
tokenizer_path = 'tokernizer/tokenizershr.pkl'
|
|
|
|
| 140 |
if not os.path.isfile(model_path):
|
| 141 |
raise FileNotFoundError(f"Model file not found: {model_path}")
|
|
|
|
| 142 |
if not os.path.isfile(tokenizer_path):
|
| 143 |
raise FileNotFoundError(f"Tokenizer file not found: {tokenizer_path}")
|
|
|
|
| 144 |
model = load_model(model_path)
|
|
|
|
| 145 |
with open(tokenizer_path, 'rb') as f:
|
| 146 |
tokenizers = pickle.load(f)
|
| 147 |
+
resume_tokenizer = tokenizers.get('resume_tokenizer')
|
| 148 |
+
description_tokenizer = tokenizers.get('description_tokenizer')
|
| 149 |
+
common_nouns_tokenizer = tokenizers.get('common_nouns_tokenizer')
|
| 150 |
+
if not (resume_tokenizer and description_tokenizer and common_nouns_tokenizer):
|
| 151 |
+
raise ValueError("Tokenizer components are missing from the file.")
|
| 152 |
+
return model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer
|
| 153 |
|
| 154 |
+
def load_model_and_tokenizers_for_it():
|
| 155 |
+
model_path = 'modelfile/bigit2.keras'
|
| 156 |
+
tokenizer_path = 'tokernizer/tokenizersit.pkl'
|
| 157 |
+
if not os.path.isfile(model_path):
|
| 158 |
+
raise FileNotFoundError(f"Model file not found: {model_path}")
|
| 159 |
+
if not os.path.isfile(tokenizer_path):
|
| 160 |
+
raise FileNotFoundError(f"Tokenizer file not found: {tokenizer_path}")
|
| 161 |
+
model = load_model(model_path)
|
| 162 |
+
with open(tokenizer_path, 'rb') as f:
|
| 163 |
+
tokenizers = pickle.load(f)
|
| 164 |
resume_tokenizer = tokenizers.get('resume_tokenizer')
|
| 165 |
description_tokenizer = tokenizers.get('description_tokenizer')
|
| 166 |
common_nouns_tokenizer = tokenizers.get('common_nouns_tokenizer')
|
| 167 |
+
if not (resume_tokenizer and description_tokenizer and common_nouns_tokenizer):
|
| 168 |
+
raise ValueError("Tokenizer components are missing from the file.")
|
| 169 |
+
return model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer
|
| 170 |
|
| 171 |
+
def load_model_and_tokenizers_for_sales():
|
| 172 |
+
model_path = 'modelfile/bigrsales2.keras'
|
| 173 |
+
tokenizer_path = 'tokernizer/tokenizerssales.pkl'
|
| 174 |
+
if not os.path.isfile(model_path):
|
| 175 |
+
raise FileNotFoundError(f"Model file not found: {model_path}")
|
| 176 |
+
if not os.path.isfile(tokenizer_path):
|
| 177 |
+
raise FileNotFoundError(f"Tokenizer file not found: {tokenizer_path}")
|
| 178 |
+
model = load_model(model_path)
|
| 179 |
+
with open(tokenizer_path, 'rb') as f:
|
| 180 |
+
tokenizers = pickle.load(f)
|
| 181 |
+
resume_tokenizer = tokenizers.get('resume_tokenizer')
|
| 182 |
+
description_tokenizer = tokenizers.get('description_tokenizer')
|
| 183 |
+
common_nouns_tokenizer = tokenizers.get('common_nouns_tokenizer')
|
| 184 |
if not (resume_tokenizer and description_tokenizer and common_nouns_tokenizer):
|
| 185 |
raise ValueError("Tokenizer components are missing from the file.")
|
| 186 |
+
return model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer
|
| 187 |
|
| 188 |
+
def load_model_and_tokenizers_for_health():
|
| 189 |
+
model_path = 'modelfile/bighealth2.keras'
|
| 190 |
+
tokenizer_path = 'tokernizer/tokenizershealth.pkl'
|
| 191 |
+
if not os.path.isfile(model_path):
|
| 192 |
+
raise FileNotFoundError(f"Model file not found: {model_path}")
|
| 193 |
+
if not os.path.isfile(tokenizer_path):
|
| 194 |
+
raise FileNotFoundError(f"Tokenizer file not found: {tokenizer_path}")
|
| 195 |
+
model = load_model(model_path)
|
| 196 |
+
with open(tokenizer_path, 'rb') as f:
|
| 197 |
+
tokenizers = pickle.load(f)
|
| 198 |
+
resume_tokenizer = tokenizers.get('resume_tokenizer')
|
| 199 |
+
description_tokenizer = tokenizers.get('description_tokenizer')
|
| 200 |
+
common_nouns_tokenizer = tokenizers.get('common_nouns_tokenizer')
|
| 201 |
+
if not (resume_tokenizer and description_tokenizer and common_nouns_tokenizer):
|
| 202 |
+
raise ValueError("Tokenizer components are missing from the file.")
|
| 203 |
return model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer
|
| 204 |
|
| 205 |
+
def load_model_and_tokenizers_for_other():
|
| 206 |
+
model_path = 'modelfile/bigothers2.keras'
|
| 207 |
+
tokenizer_path = 'tokernizer/tokenizersothers.pkl'
|
| 208 |
+
if not os.path.isfile(model_path):
|
| 209 |
+
raise FileNotFoundError(f"Model file not found: {model_path}")
|
| 210 |
+
if not os.path.isfile(tokenizer_path):
|
| 211 |
+
raise FileNotFoundError(f"Tokenizer file not found: {tokenizer_path}")
|
| 212 |
+
model = load_model(model_path)
|
| 213 |
+
with open(tokenizer_path, 'rb') as f:
|
| 214 |
+
tokenizers = pickle.load(f)
|
| 215 |
+
resume_tokenizer = tokenizers.get('resume_tokenizer')
|
| 216 |
+
description_tokenizer = tokenizers.get('description_tokenizer')
|
| 217 |
+
common_nouns_tokenizer = tokenizers.get('common_nouns_tokenizer')
|
| 218 |
+
if not (resume_tokenizer and description_tokenizer and common_nouns_tokenizer):
|
| 219 |
+
raise ValueError("Tokenizer components are missing from the file.")
|
| 220 |
+
return model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
# Streamlit UI
|
| 223 |
st.title("ATS")
|
|
|
|
| 231 |
job_description = st.text_area("Paste Job Description:", height=150)
|
| 232 |
|
| 233 |
# Sector selection
|
| 234 |
+
sector = st.selectbox("Select Sector:", ['HR', 'IT', 'Sales', 'Health', 'Other'])
|
| 235 |
|
| 236 |
if st.button("Calculate ATS Score"):
|
| 237 |
if resume and job_description:
|
| 238 |
try:
|
| 239 |
+
if sector == 'HR':
|
| 240 |
+
model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer = load_model_and_tokenizers_for_hr()
|
| 241 |
+
elif sector == 'IT':
|
| 242 |
+
model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer = load_model_and_tokenizers_for_it()
|
| 243 |
+
elif sector == 'Sales':
|
| 244 |
+
model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer = load_model_and_tokenizers_for_sales()
|
| 245 |
+
elif sector == 'Health':
|
| 246 |
+
model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer = load_model_and_tokenizers_for_health()
|
| 247 |
+
elif sector == 'Other':
|
| 248 |
+
model, resume_tokenizer, description_tokenizer, common_nouns_tokenizer = load_model_and_tokenizers_for_other()
|
| 249 |
|
| 250 |
processed_resume = clean_and_preprocess(resume)
|
| 251 |
processed_description = clean_and_preprocess(job_description)
|