Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from cv_analyzer import analyze_cv | |
| from cv_quality import CV | |
| from get_supabase import Supabase | |
| from datetime import datetime | |
| st.set_page_config(page_title="CV Analyzer", layout="wide") | |
| st.title('CV Analyzer') | |
| # Initialize Supabase client | |
| supabase_client = Supabase().init_supabase_client() | |
| # Supabase storage details | |
| BUCKET_NAME = "CVs UX" | |
| SUPABASE_PROJECT_ID = "abjtqzgnrtsikkqgnqeg" | |
| # Get list of files from the Supabase bucket | |
| files = supabase_client.storage.from_(BUCKET_NAME).list() | |
| file_names = [file['name'] for file in files] | |
| # Create a dropdown to select the file | |
| selected_file = st.selectbox("Select a CV to analyze", file_names) | |
| if selected_file: | |
| with st.spinner('Analyzing CV...'): | |
| # Construct the public URL of the selected file | |
| timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ") | |
| file_url = f"https://{SUPABASE_PROJECT_ID}.supabase.co/storage/v1/object/public/{BUCKET_NAME}/{selected_file}?t={timestamp}" | |
| # Create CV object with the file URL | |
| cv = CV(file_url) | |
| result = cv.analyse_cv_quality() | |
| if "error" in result: | |
| st.error(result["error"]) | |
| else: | |
| # Display results | |
| st.header("Personal Information") | |
| personal_info = result["personal_info"] | |
| st.json(personal_info) | |
| st.write(f"Personal Information Score: {personal_info['personal_info_score']}") | |
| st.header("Detected Sections") | |
| st.write(result["detected_sections"]) | |
| st.write(f"Section Detection Score: {result['section_detection_score']}") | |
| st.header("Spelling and Grammar") | |
| st.write(f"Error Percentage: {result['spelling_grammar_error_percentage']:.2f}%") | |
| st.write(f"Spelling and Grammar Score: {result['spelling_grammar_score']}") | |
| st.header("Content Quality Analysis") | |
| for section, evaluation in result['content_analysis'].items(): | |
| st.subheader(section.capitalize()) | |
| st.json(evaluation) | |
| st.write(f"Overall Content Quality Score: {result['overall_score']:.2f} / 10") | |
| st.header("Total CV Score") | |
| total_score = ( | |
| personal_info['personal_info_score'] + | |
| result['section_detection_score'] + | |
| result['spelling_grammar_score'] + | |
| result['overall_score'] | |
| ) | |
| st.write(f"Total Score: {total_score:.2f}") | |
| if __name__ == "__main__": | |
| st.sidebar.title("About") | |
| st.sidebar.info( | |
| "This CV Analyzer extracts personal information, detects sections, " | |
| "checks spelling and grammar, analyzes content quality, " | |
| "and provides a detailed evaluation of the CV." | |
| ) |