Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
-
# app.py
|
| 2 |
-
|
| 3 |
import streamlit as st
|
| 4 |
import asyncio
|
| 5 |
from cv_analyzer import process_cv
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
st.set_page_config(page_title="CV Analyzer", page_icon="📄", layout="wide")
|
| 8 |
|
|
@@ -12,46 +14,55 @@ def main():
|
|
| 12 |
uploaded_file = st.file_uploader("Choose a CV file", type=["pdf", "png", "jpg", "jpeg"])
|
| 13 |
|
| 14 |
if uploaded_file is not None:
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
st.write(f"
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
st.write(f"
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
if __name__ == "__main__":
|
| 57 |
main()
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import asyncio
|
| 3 |
from cv_analyzer import process_cv
|
| 4 |
+
import logging
|
| 5 |
+
|
| 6 |
+
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
| 7 |
+
logger = logging.getLogger(__name__)
|
| 8 |
|
| 9 |
st.set_page_config(page_title="CV Analyzer", page_icon="📄", layout="wide")
|
| 10 |
|
|
|
|
| 14 |
uploaded_file = st.file_uploader("Choose a CV file", type=["pdf", "png", "jpg", "jpeg"])
|
| 15 |
|
| 16 |
if uploaded_file is not None:
|
| 17 |
+
try:
|
| 18 |
+
file_contents = uploaded_file.read()
|
| 19 |
+
st.write(f"File size: {len(file_contents)} bytes")
|
| 20 |
+
st.write(f"File type: {uploaded_file.type}")
|
| 21 |
+
|
| 22 |
+
with st.spinner("Analyzing CV..."):
|
| 23 |
+
try:
|
| 24 |
+
result = asyncio.run(process_cv(uploaded_file))
|
| 25 |
+
|
| 26 |
+
st.subheader("Analysis Results")
|
| 27 |
+
|
| 28 |
+
st.write("1. Personal Information:")
|
| 29 |
+
st.json(result["personalInfo"]["info"])
|
| 30 |
+
st.write(f"Score: {result['personalInfo']['score']}/{result['personalInfo']['max_score']}")
|
| 31 |
+
|
| 32 |
+
st.write("2. Spelling and Grammar:")
|
| 33 |
+
st.write(f"Error Percentage: {result['spellingGrammar']['error_percentage']:.2f}%")
|
| 34 |
+
st.write(f"Score: {result['spellingGrammar']['score']}/{result['spellingGrammar']['max_score']}")
|
| 35 |
+
|
| 36 |
+
st.write("3. Completeness:")
|
| 37 |
+
st.write("Present Sections:")
|
| 38 |
+
for section, is_present in result['completeness']['present_sections'].items():
|
| 39 |
+
st.write(f" - {section}: {'Present' if is_present else 'Not Present'}")
|
| 40 |
+
st.write(f"Score: {result['completeness']['score']}/{result['completeness']['max_score']}")
|
| 41 |
+
|
| 42 |
+
st.write("4. Content Quality:")
|
| 43 |
+
for section, quality in result["contentQuality"].items():
|
| 44 |
+
st.write(f"{section}:")
|
| 45 |
+
st.write(f" Overall Score: {quality['overall_score']:.1f}/{quality['max_score']}")
|
| 46 |
+
st.write(f" Feedback: {quality['overall_feedback']}")
|
| 47 |
+
if quality['subsection_scores']:
|
| 48 |
+
st.write(" Subsection Scores:")
|
| 49 |
+
for i, subsection in enumerate(quality['subsection_scores'], 1):
|
| 50 |
+
st.write(f" Subsection {i}:")
|
| 51 |
+
for element, score in subsection.items():
|
| 52 |
+
st.write(f" - {element}: {score:.1f}")
|
| 53 |
+
|
| 54 |
+
st.subheader("Total Score")
|
| 55 |
+
st.write(f"{result['totalScore']:.1f}/{result['maxTotalScore']}")
|
| 56 |
+
|
| 57 |
+
st.subheader("Detailed Analysis")
|
| 58 |
+
st.json(result)
|
| 59 |
+
|
| 60 |
+
except Exception as e:
|
| 61 |
+
logger.exception("An error occurred during analysis")
|
| 62 |
+
st.error(f"An error occurred during analysis: {str(e)}")
|
| 63 |
+
except Exception as e:
|
| 64 |
+
logger.exception("Error reading file")
|
| 65 |
+
st.error(f"Error reading file: {str(e)}")
|
| 66 |
|
| 67 |
if __name__ == "__main__":
|
| 68 |
main()
|