Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,16 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import pdfplumber
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
classify_field
|
| 9 |
-
)
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
st.set_page_config(page_title="Skill Scoring & Roadmap App", layout="wide")
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Load datasets
|
| 15 |
skills_df = pd.read_csv("data/skills_dataset.csv")
|
|
@@ -17,9 +18,22 @@ countries_df = pd.read_csv("data/countries_dataset.csv")
|
|
| 17 |
cert_df = pd.read_csv("data/certifications.csv")
|
| 18 |
edu_tech_df = pd.read_csv("data/education_technical.csv")
|
| 19 |
edu_non_tech_df = pd.read_csv("data/education_non_technical.csv")
|
| 20 |
-
scholarship_df = pd.read_csv("data/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
# Helper function
|
| 23 |
def score_skills(user_skills):
|
| 24 |
if not skills_df.shape[0]:
|
| 25 |
return 0
|
|
@@ -39,23 +53,48 @@ def recommend_education(background):
|
|
| 39 |
def recommend_scholarships(field):
|
| 40 |
return scholarship_df[scholarship_df["Field"].str.lower() == field.lower()].reset_index(drop=True)
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
uploaded_file = st.file_uploader("π€ Upload your CV (PDF
|
| 47 |
|
| 48 |
if uploaded_file:
|
| 49 |
with st.spinner("Analyzing your CV..."):
|
| 50 |
text = extract_text_from_pdf(uploaded_file)
|
| 51 |
-
skills, background = extract_entities(text
|
| 52 |
-
years_exp = extract_experience_years(text)
|
| 53 |
-
field = classify_field(text)
|
| 54 |
-
|
| 55 |
score = score_skills(skills)
|
| 56 |
country_info = recommend_countries(skills, years_exp)
|
| 57 |
certs = recommend_certifications(skills)
|
| 58 |
edu = recommend_education(background)
|
|
|
|
| 59 |
scholarships = recommend_scholarships(field)
|
| 60 |
|
| 61 |
st.subheader("β
Identified Skills")
|
|
@@ -64,34 +103,57 @@ if uploaded_file:
|
|
| 64 |
st.subheader("π Skill Score")
|
| 65 |
st.metric("Your Skill Score", f"{score}/100")
|
| 66 |
|
| 67 |
-
st.subheader("
|
| 68 |
-
st.write(f"{years_exp} years of experience detected.")
|
| 69 |
-
|
| 70 |
-
st.subheader("π Categorized Field")
|
| 71 |
-
st.write(f"Detected Field: `{field}` | Background: `{background}`")
|
| 72 |
-
|
| 73 |
-
st.subheader("π Country Recommendations")
|
| 74 |
if not country_info.empty:
|
| 75 |
st.dataframe(country_info)
|
| 76 |
else:
|
| 77 |
-
st.write("No
|
| 78 |
|
| 79 |
-
st.subheader("π
|
| 80 |
if not certs.empty:
|
| 81 |
st.dataframe(certs)
|
| 82 |
else:
|
| 83 |
-
st.write("No certification recommendations
|
| 84 |
|
| 85 |
-
st.subheader("π Higher Education")
|
| 86 |
if not edu.empty:
|
| 87 |
st.dataframe(edu)
|
| 88 |
else:
|
| 89 |
-
st.write("No higher education
|
| 90 |
|
| 91 |
st.subheader("π Scholarship Opportunities")
|
| 92 |
if not scholarships.empty:
|
| 93 |
st.dataframe(scholarships)
|
| 94 |
else:
|
| 95 |
-
st.write("No
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
else:
|
| 97 |
st.info("Please upload your CV to begin.")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import pdfplumber
|
| 4 |
+
import spacy
|
| 5 |
+
import requests
|
| 6 |
+
import plotly.express as px
|
| 7 |
+
from datetime import datetime, timedelta
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
# Page config
|
| 10 |
+
st.set_page_config(page_title="Skill Scoring & Career Roadmap App", layout="wide")
|
| 11 |
+
|
| 12 |
+
# Load spaCy model
|
| 13 |
+
nlp = spacy.load("en_core_web_sm")
|
| 14 |
|
| 15 |
# Load datasets
|
| 16 |
skills_df = pd.read_csv("data/skills_dataset.csv")
|
|
|
|
| 18 |
cert_df = pd.read_csv("data/certifications.csv")
|
| 19 |
edu_tech_df = pd.read_csv("data/education_technical.csv")
|
| 20 |
edu_non_tech_df = pd.read_csv("data/education_non_technical.csv")
|
| 21 |
+
scholarship_df = pd.read_csv("data/scholarships_dataset.csv")
|
| 22 |
+
|
| 23 |
+
# Helper functions
|
| 24 |
+
def extract_text_from_pdf(file):
|
| 25 |
+
with pdfplumber.open(file) as pdf:
|
| 26 |
+
return "\n".join(page.extract_text() for page in pdf.pages if page.extract_text())
|
| 27 |
+
|
| 28 |
+
def extract_entities(text):
|
| 29 |
+
doc = nlp(text)
|
| 30 |
+
skills = [token.text for token in doc if token.text in skills_df['Skill'].values]
|
| 31 |
+
technical_skills = {"Python", "Machine Learning", "Cloud Computing", "Cybersecurity", "AI", "DevOps"}
|
| 32 |
+
background = "technical" if any(s in technical_skills for s in skills) else "non-technical"
|
| 33 |
+
# Dummy experience extraction (you should improve with NLP)
|
| 34 |
+
years_exp = 3 # Placeholder, replace with better extraction logic
|
| 35 |
+
return list(set(skills)), background, years_exp
|
| 36 |
|
|
|
|
| 37 |
def score_skills(user_skills):
|
| 38 |
if not skills_df.shape[0]:
|
| 39 |
return 0
|
|
|
|
| 53 |
def recommend_scholarships(field):
|
| 54 |
return scholarship_df[scholarship_df["Field"].str.lower() == field.lower()].reset_index(drop=True)
|
| 55 |
|
| 56 |
+
def fetch_jobs(skill, country_code="us", max_results=5):
|
| 57 |
+
app_id = "YOUR_ADZUNA_APP_ID"
|
| 58 |
+
app_key = "YOUR_ADZUNA_APP_KEY"
|
| 59 |
+
url = f"https://api.adzuna.com/v1/api/jobs/{country_code}/search/1"
|
| 60 |
+
params = {
|
| 61 |
+
"app_id": app_id,
|
| 62 |
+
"app_key": app_key,
|
| 63 |
+
"results_per_page": max_results,
|
| 64 |
+
"what": skill,
|
| 65 |
+
"content-type": "application/json"
|
| 66 |
+
}
|
| 67 |
+
response = requests.get(url, params=params)
|
| 68 |
+
if response.status_code == 200:
|
| 69 |
+
return response.json()["results"]
|
| 70 |
+
else:
|
| 71 |
+
return []
|
| 72 |
+
|
| 73 |
+
def create_roadmap_timeline():
|
| 74 |
+
# Example roadmap with skill cert + scholarships + education timelines
|
| 75 |
+
now = datetime.now()
|
| 76 |
+
roadmap = [
|
| 77 |
+
{"Task": "Complete Python Certification", "Start": now.strftime("%Y-%m-%d"), "Finish": (now + timedelta(days=90)).strftime("%Y-%m-%d")},
|
| 78 |
+
{"Task": "Apply for Erasmus Scholarship", "Start": (now + timedelta(days=100)).strftime("%Y-%m-%d"), "Finish": (now + timedelta(days=150)).strftime("%Y-%m-%d")},
|
| 79 |
+
{"Task": "Master's in AI (Online)", "Start": (now + timedelta(days=160)).strftime("%Y-%m-%d"), "Finish": (now + timedelta(days=700)).strftime("%Y-%m-%d")},
|
| 80 |
+
]
|
| 81 |
+
return pd.DataFrame(roadmap)
|
| 82 |
+
|
| 83 |
+
# Streamlit UI
|
| 84 |
+
st.title("π Personalized Skill Scoring & Career Roadmap App")
|
| 85 |
+
st.markdown("Upload your CV and get a detailed career roadmap with live job listings.")
|
| 86 |
|
| 87 |
+
uploaded_file = st.file_uploader("π€ Upload your CV (PDF only)", type=["pdf"])
|
| 88 |
|
| 89 |
if uploaded_file:
|
| 90 |
with st.spinner("Analyzing your CV..."):
|
| 91 |
text = extract_text_from_pdf(uploaded_file)
|
| 92 |
+
skills, background, years_exp = extract_entities(text)
|
|
|
|
|
|
|
|
|
|
| 93 |
score = score_skills(skills)
|
| 94 |
country_info = recommend_countries(skills, years_exp)
|
| 95 |
certs = recommend_certifications(skills)
|
| 96 |
edu = recommend_education(background)
|
| 97 |
+
field = background # Simplified; you should detect actual field from CV
|
| 98 |
scholarships = recommend_scholarships(field)
|
| 99 |
|
| 100 |
st.subheader("β
Identified Skills")
|
|
|
|
| 103 |
st.subheader("π Skill Score")
|
| 104 |
st.metric("Your Skill Score", f"{score}/100")
|
| 105 |
|
| 106 |
+
st.subheader("π Job Opportunities & Country Recommendations")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
if not country_info.empty:
|
| 108 |
st.dataframe(country_info)
|
| 109 |
else:
|
| 110 |
+
st.write("No country/job recommendations available for your skill set.")
|
| 111 |
|
| 112 |
+
st.subheader("π Recommended Certifications")
|
| 113 |
if not certs.empty:
|
| 114 |
st.dataframe(certs)
|
| 115 |
else:
|
| 116 |
+
st.write("No certification recommendations available.")
|
| 117 |
|
| 118 |
+
st.subheader("π Higher Education Opportunities")
|
| 119 |
if not edu.empty:
|
| 120 |
st.dataframe(edu)
|
| 121 |
else:
|
| 122 |
+
st.write("No higher education opportunities available.")
|
| 123 |
|
| 124 |
st.subheader("π Scholarship Opportunities")
|
| 125 |
if not scholarships.empty:
|
| 126 |
st.dataframe(scholarships)
|
| 127 |
else:
|
| 128 |
+
st.write("No scholarships available for your field.")
|
| 129 |
+
|
| 130 |
+
# Timeline chart for roadmap
|
| 131 |
+
st.subheader("π€οΈ Your Career Roadmap Timeline")
|
| 132 |
+
timeline_df = create_roadmap_timeline()
|
| 133 |
+
fig = px.timeline(timeline_df, x_start="Start", x_end="Finish", y="Task", title="Career Roadmap Timeline")
|
| 134 |
+
fig.update_yaxes(autorange="reversed")
|
| 135 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 136 |
+
|
| 137 |
+
# Show live job listings using first identified skill and first country code (you can improve this logic)
|
| 138 |
+
if skills and not country_info.empty:
|
| 139 |
+
st.subheader(f"π Live Job Listings for '{skills[0]}'")
|
| 140 |
+
country_code_map = {
|
| 141 |
+
"USA": "us",
|
| 142 |
+
"Canada": "ca",
|
| 143 |
+
"UK": "gb",
|
| 144 |
+
"Germany": "de",
|
| 145 |
+
"Australia": "au",
|
| 146 |
+
"India": "in",
|
| 147 |
+
"Netherlands": "nl"
|
| 148 |
+
}
|
| 149 |
+
country_code = country_code_map.get(country_info.iloc[0]["Country"], "us")
|
| 150 |
+
jobs = fetch_jobs(skills[0], country_code=country_code, max_results=5)
|
| 151 |
+
if jobs:
|
| 152 |
+
for job in jobs:
|
| 153 |
+
st.markdown(f"**[{job['title']}]({job['redirect_url']})** - {job['location']['display_name']}")
|
| 154 |
+
st.markdown(f"*{job.get('description', '')[:200]}...*")
|
| 155 |
+
st.markdown("---")
|
| 156 |
+
else:
|
| 157 |
+
st.write("No live job listings found.")
|
| 158 |
else:
|
| 159 |
st.info("Please upload your CV to begin.")
|