Spaces:
Sleeping
Sleeping
Download app.py from deepsu/cv_job_classifier: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/deepsu/cv_job_classifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/deepsu/cv_job_classifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/deepsu/cv_job_classifier/resolve/main/app.py
1.03 kB
| import gradio as gr | |
| from sentence_transformers import SentenceTransformer, util | |
| import re | |
| model = SentenceTransformer("./model") | |
| def preprocess(text): | |
| text = text.lower() | |
| text = re.sub(r"[^\w\s]", "", text) | |
| remove_words = [ | |
| "summary", "experience", "experiences", | |
| "education", "educations", "skill", "skills", | |
| "role", "roles" | |
| ] | |
| for word in remove_words: | |
| text = re.sub(rf"\b{word}\b", "", text) | |
| text = re.sub(r"\s+", " ", text).strip() | |
| return text | |
| def match(cv, job): | |
| cv = preprocess(cv) | |
| job = preprocess(job) | |
| cv_emb = model.encode(cv) | |
| job_emb = model.encode(job) | |
| score = util.cos_sim(cv_emb, job_emb).item() | |
| return {"score": round(score, 4)} | |
| interface = gr.Interface( | |
| fn=match, | |
| inputs=[ | |
| gr.Textbox(label="CV Text"), | |
| gr.Textbox(label="Job Description") | |
| ], | |
| outputs=gr.JSON(), | |
| title="CV Matching API" | |
| ) | |
| interface.launch( | |
| server_name="0.0.0.0", # required for hosted Spaces | |
| server_port=7860, | |
| ) |