File size: 2,773 Bytes
200a5fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7aea58f
 
 
200a5fd
7aea58f
 
200a5fd
7aea58f
 
 
200a5fd
7aea58f
200a5fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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."
    )