Spaces:
Sleeping
Sleeping
Update app.py
Browse files149 unmodified lines1501511521531541551561571581591601531541551 unmodified line15715815916016116216316416516616716816917024 unmodified lines1951961971981981992002012022032032042052063 unmodified lines2102112122132142152162172182192202212132142152162172242182192202282212222232241 unmodified line226227228236237238239240241242243244245246247248249250229230231232233234235236237238252239240241242243244245149 unmodified lines st.title("Job Search Application") st.write("Find jobs that match your preferences!")
# Initialize session state for expanded descriptions if 'expanded_descriptions' not in st.session_state: st.session_state.expanded_descriptions = {} if 'search_performed' not in st.session_state: st.session_state.search_performed = False if 'filtered_jobs' not in st.session_state: st.session_state.filtered_jobs = pd.DataFrame()
# Load data url = "https://huggingface.co/datasets/burcuonel/datajob_indeed_usa/raw/main/datajob_indeed_usa.csv" jobs_df = load_and_preprocess_data(url)1 unmodified line if jobs_df is None: return
# Initialize session state if 'search_performed' not in st.session_state: st.session_state.search_performed = False if 'filtered_jobs' not in st.session_state: st.session_state.filtered_jobs = pd.DataFrame() if 'expanded_descriptions' not in st.session_state: st.session_state.expanded_descriptions = set()
# Sidebar filters with st.sidebar: st.header("Search Filters")24 unmodified lines ) st.session_state.search_performed = True # Reset expanded descriptions when new search is performed st.session_state.expanded_descriptions = {} st.session_state.expanded_descriptions = set()
if st.button("Reset Filters", use_container_width=True): st.session_state.search_performed = False st.session_state.filtered_jobs = pd.DataFrame() st.session_state.expanded_descriptions = {} st.session_state.expanded_descriptions = set() st.rerun()
# Display results3 unmodified lines
if not filtered_jobs.empty: for index, row in filtered_jobs.iterrows(): job_key = f"job_{index}" with st.expander(f"{row['Title']} - {row['Location']}", expanded=True): col1, col2 = st.columns(2) with col1: st.write(f"**Salary:** {row['Salary']}") with col2: st.write(f"**Cleaned Salary:** ${row['clean_salary']:,}") with st.expander(f"{row['Title']} - {row['Location']}"): st.write(f"**Salary:** {row['Salary']}") st.write(f"**Cleaned Salary:** {row['clean_salary']}") if 'cluster' in row: st.write(f"**Cluster:** {row['cluster']}") st.write("**Description:**") description = row['Description']
# Highlight keywords if any # Highlight keywords if keywords: keyword_list = [k.strip() for k in keywords.split(',')] for keyword in keyword_list:1 unmodified line pattern = re.compile(f'({re.escape(keyword)})', re.IGNORECASE) description = pattern.sub(r'**\1**', description)
# Show truncated or full description based on state if len(description) > 500: if not job_key in st.session_state.expanded_descriptions: st.session_state.expanded_descriptions[job_key] = False if st.session_state.expanded_descriptions[job_key]: st.markdown(description) if st.button("Show Less", key=f"button_{index}_less"): st.session_state.expanded_descriptions[job_key] = False st.rerun() else: st.markdown(description[:500] + "...") if st.button("Show More", key=f"button_{index}_more"): st.session_state.expanded_descriptions[job_key] = True st.rerun() # Check if this description is expanded is_expanded = index in st.session_state.expanded_descriptions # Show full or truncated description based on state if len(description) > 500 and not is_expanded: st.write(description[:500] + "...") if st.button("See more", key=f"expand_{index}"): st.session_state.expanded_descriptions.add(index) st.rerun() else: st.markdown(description) st.write(description) if len(description) > 500 and st.button("See less", key=f"collapse_{index}"): st.session_state.expanded_descriptions.remove(index) st.rerun() else: st.warning(""" No matching jobs found. Try:app.py+27-37