Nassira commited on
Commit
8bbe3d1
·
verified ·
1 Parent(s): 47968e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -42
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
- with st.spinner("Analyzing CV..."):
16
- try:
17
- result = asyncio.run(process_cv(uploaded_file))
18
-
19
- st.subheader("Analysis Results")
20
-
21
- st.write("1. Personal Information:")
22
- st.json(result["personalInfo"]["info"])
23
- st.write(f"Score: {result['personalInfo']['score']}/{result['personalInfo']['max_score']}")
24
-
25
- st.write("2. Spelling and Grammar:")
26
- st.write(f"Error Percentage: {result['spellingGrammar']['error_percentage']:.2f}%")
27
- st.write(f"Score: {result['spellingGrammar']['score']}/{result['spellingGrammar']['max_score']}")
28
-
29
- st.write("3. Completeness:")
30
- st.write("Present Sections:")
31
- for section, is_present in result['completeness']['present_sections'].items():
32
- st.write(f" - {section}: {'Present' if is_present else 'Not Present'}")
33
- st.write(f"Score: {result['completeness']['score']}/{result['completeness']['max_score']}")
34
-
35
- st.write("4. Content Quality:")
36
- for section, quality in result["contentQuality"].items():
37
- st.write(f"{section}:")
38
- st.write(f" Overall Score: {quality['overall_score']:.1f}/{quality['max_score']}")
39
- st.write(f" Feedback: {quality['overall_feedback']}")
40
- if quality['subsection_scores']:
41
- st.write(" Subsection Scores:")
42
- for i, subsection in enumerate(quality['subsection_scores'], 1):
43
- st.write(f" Subsection {i}:")
44
- for element, score in subsection.items():
45
- st.write(f" - {element}: {score:.1f}")
46
-
47
- st.subheader("Total Score")
48
- st.write(f"{result['totalScore']:.1f}/{result['maxTotalScore']}")
49
-
50
- st.subheader("Detailed Analysis")
51
- st.json(result)
52
-
53
- except Exception as e:
54
- st.error(f"An error occurred during analysis: {str(e)}")
 
 
 
 
 
 
 
 
 
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()