Spaces:
Running
Running
Download utils.py from Json026/ATS_Scorer: direct link, hf CLI and curl.
- Browser
- Download file 576 Bytes
-
https://huggingface.co/spaces/Json026/ATS_Scorer/resolve/main/utils.py
- Command line
-
hf download hf://spaces/Json026/ATS_Scorer/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/Json026/ATS_Scorer/resolve/main/utils.py
576 Bytes
| import fitz | |
| from sklearn.feature_extraction.text import TfidfVectorizer | |
| from sklearn.metrics.pairwise import cosine_similarity | |
| def extract_text_from_pdf(file): | |
| text = "" | |
| pdf = fitz.open(stream=file.read(), filetype="pdf") | |
| for page in pdf: | |
| text += page.get_text() | |
| return text | |
| def calculate_similarity(resume_text, job_desc): | |
| vectorizer = TfidfVectorizer(stop_words="english") | |
| vectors = vectorizer.fit_transform([resume_text, job_desc]) | |
| similarity = cosine_similarity(vectors[0:1], vectors[1:2])[0][0] | |
| return round(similarity * 100, 2) |