File size: 2,231 Bytes
e3de01a 373133f 6a61f01 e3de01a 981a9a7 6a61f01 981a9a7 6a61f01 e3de01a 6a61f01 981a9a7 6a61f01 e3de01a 6a61f01 27b3f1b e3de01a 6a61f01 | 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 | import streamlit as st
import asyncio
import json
from cv_analyzer import process_cv
st.set_page_config(page_title="CV Analyzer", page_icon="📄", layout="wide")
@st.cache_data
def cached_process_cv(_file):
return None # Cette fonction ne fait rien maintenant, mais permet de conserver le cache pour le fichier
def display_section(title, content):
st.write(f"**{title}**")
st.write(content)
async def analyze_cv(file):
return await process_cv(file)
def main():
st.title("CV Analyzer")
uploaded_file = st.file_uploader("Choose a CV file", type=["pdf", "png", "jpg", "jpeg"])
if uploaded_file:
# Utiliser le cache pour vérifier si le fichier a déjà été analysé
cache_key = cached_process_cv(uploaded_file)
with st.spinner("Analyzing CV..."):
try:
# Exécuter l'analyse de manière asynchrone
result = asyncio.run(analyze_cv(uploaded_file))
col1, col2 = st.columns(2)
with col1:
display_section("Personal Information", f"Score: {result['personalInfo']['score']}/{result['personalInfo']['max_score']}")
st.json(result["personalInfo"]["info"])
display_section("Spelling and Grammar", f"Error %: {result['spellingGrammar']['error_percentage']:.2f}%\nScore: {result['spellingGrammar']['score']}/{result['spellingGrammar']['max_score']}")
with col2:
display_section("Completeness", f"Score: {result['completeness']['score']}/{result['completeness']['max_score']}")
st.write("Present Sections:")
st.json(result['completeness']['present_sections'])
display_section("Content Quality", "")
for section, quality in result["contentQuality"].items():
st.write(f"{section}: {quality['overall_score']:.1f}/{quality['max_score']}")
st.subheader(f"Total Score: {result['totalScore']:.1f}/{result['maxTotalScore']}")
except Exception as e:
st.error(f"An error occurred during analysis: {str(e)}")
if __name__ == "__main__":
main() |