Spaces:
Sleeping
Sleeping
Update extractor.py
Browse files- extractor.py +11 -10
extractor.py
CHANGED
|
@@ -1,19 +1,20 @@
|
|
| 1 |
-
import pdfplumber
|
| 2 |
import spacy
|
| 3 |
|
| 4 |
nlp = spacy.load("en_core_web_sm")
|
| 5 |
|
| 6 |
def extract_text_from_pdf(file):
|
|
|
|
| 7 |
with pdfplumber.open(file) as pdf:
|
| 8 |
-
return "\n".join(
|
| 9 |
|
| 10 |
-
def extract_entities(text
|
| 11 |
doc = nlp(text)
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
years_exp = 3
|
| 19 |
-
return skills, background, years_exp
|
|
|
|
|
|
|
| 1 |
import spacy
|
| 2 |
|
| 3 |
nlp = spacy.load("en_core_web_sm")
|
| 4 |
|
| 5 |
def extract_text_from_pdf(file):
|
| 6 |
+
import pdfplumber
|
| 7 |
with pdfplumber.open(file) as pdf:
|
| 8 |
+
return "\n".join(page.extract_text() for page in pdf.pages if page.extract_text())
|
| 9 |
|
| 10 |
+
def extract_entities(text):
|
| 11 |
doc = nlp(text)
|
| 12 |
+
# Extract skills by matching tokens to skills list externally
|
| 13 |
+
# Here we just return all nouns as a placeholder
|
| 14 |
+
skills = [token.text for token in doc if token.pos_ in ("NOUN", "PROPN")]
|
| 15 |
+
# Determine background (simplified)
|
| 16 |
+
technical_skills = {"Python", "Machine Learning", "Cloud Computing", "Cybersecurity", "AI", "DevOps"}
|
| 17 |
+
background = "technical" if any(skill in technical_skills for skill in skills) else "non-technical"
|
| 18 |
+
# Dummy experience years
|
| 19 |
years_exp = 3
|
| 20 |
+
return list(set(skills)), background, years_exp
|