Download app.py from Nassira/wt: direct link, hf CLI and curl.
- Browser
- Download file 2.42 kB
-
https://huggingface.co/spaces/Nassira/wt/resolve/main/app.py
- Command line
-
hf download hf://spaces/Nassira/wt/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Nassira/wt/resolve/main/app.py
2.42 kB
| import streamlit as st | |
| import json | |
| from cv_analyzer import analyze_cv | |
| st.set_page_config(page_title="CV Analyzer", layout="wide") | |
| st.title('CV Analyzer') | |
| uploaded_file = st.file_uploader("Choose a CV file", type=['pdf', 'docx', 'txt']) | |
| if uploaded_file is not None: | |
| file_content = uploaded_file.read() | |
| with st.spinner('Analyzing CV...'): | |
| result = analyze_cv(file_content) | |
| if "error" in result: | |
| st.error(result["error"]) | |
| else: | |
| st.header("Detected Sections") | |
| st.write(result["detected_sections"]) | |
| st.header("Content Quality Score") | |
| st.write(f"Overall Score: {result['content_quality_score']:.2f} / 10") | |
| st.header("Content Quality Analysis") | |
| # Create a new dictionary to store the modified content analysis | |
| modified_content_analysis = {"sections": []} | |
| for section in result["content_analysis"]["sections"]: | |
| modified_section = { | |
| "name": section["name"], | |
| "present": section["present"], | |
| "score": 0, # Initialize section score | |
| "subsections": [] | |
| } | |
| if "subsections" in section: | |
| for subsection in section["subsections"]: | |
| modified_subsection = { | |
| "elements": [] | |
| } | |
| for element in subsection["elements"]: | |
| modified_element = { | |
| "name": element["name"], | |
| "present": element["present"], | |
| "score": element.get("score", 0), # Add score if available | |
| "content": element.get("content", "") if element["present"] == "yes" else "" | |
| } | |
| modified_subsection["elements"].append(modified_element) | |
| modified_section["score"] += modified_element["score"] | |
| modified_section["subsections"].append(modified_subsection) | |
| modified_content_analysis["sections"].append(modified_section) | |
| st.json(modified_content_analysis) | |
| if __name__ == "__main__": | |
| st.sidebar.title("About") | |
| st.sidebar.info( | |
| "This CV Analyzer displays detected sections, their scores, " | |
| "and the content quality analysis in JSON format." | |
| ) |