Nassira commited on
Commit
55f3d20
·
verified ·
1 Parent(s): 793e64b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -16
app.py CHANGED
@@ -7,6 +7,7 @@ from typing import List, Dict, Tuple, Any
7
  import time
8
  import asyncio
9
  from llm_functions import extract_personal_info, check_spelling_grammar, identify_sections, assess_section_quality
 
10
 
11
  # Set page config
12
  st.set_page_config(page_title="CV Analyzer", page_icon="📄", layout="wide")
@@ -64,7 +65,6 @@ def analyze_cv(cv_content: str) -> Dict[str, Any]:
64
  personal_info_score = sum(1 for value in personal_info.values() if value is not None and value != "null")
65
  personal_info_max_score = 4
66
 
67
- spelling_grammar = float(spelling_grammar)
68
  spelling_grammar_score = calculate_spelling_grammar_score(spelling_grammar)
69
  spelling_grammar_max_score = 5
70
 
@@ -87,29 +87,16 @@ def analyze_cv(cv_content: str) -> Dict[str, Any]:
87
 
88
  return asyncio.run(async_analyze())
89
 
90
- def read_file_content(uploaded_file):
91
- bytes_data = uploaded_file.getvalue()
92
- encodings = ['utf-8', 'iso-8859-1', 'windows-1252']
93
-
94
- for encoding in encodings:
95
- try:
96
- return bytes_data.decode(encoding)
97
- except UnicodeDecodeError:
98
- continue
99
-
100
- st.error("Unable to decode the file. Please ensure the file is text-based and try again.")
101
- return None
102
-
103
  # Streamlit app
104
  def main():
105
  st.title("CV Analyzer")
106
 
107
- uploaded_file = st.file_uploader("Choose a CV file", type=["txt", "pdf", "docx"])
108
 
109
  if uploaded_file is not None:
110
  cv_content = read_file_content(uploaded_file)
111
  if cv_content:
112
- st.text_area("CV Content", cv_content, height=200)
113
 
114
  if st.button("Analyze CV"):
115
  with st.spinner("Analyzing CV..."):
 
7
  import time
8
  import asyncio
9
  from llm_functions import extract_personal_info, check_spelling_grammar, identify_sections, assess_section_quality
10
+ from cv_content_extractor import read_file_content
11
 
12
  # Set page config
13
  st.set_page_config(page_title="CV Analyzer", page_icon="📄", layout="wide")
 
65
  personal_info_score = sum(1 for value in personal_info.values() if value is not None and value != "null")
66
  personal_info_max_score = 4
67
 
 
68
  spelling_grammar_score = calculate_spelling_grammar_score(spelling_grammar)
69
  spelling_grammar_max_score = 5
70
 
 
87
 
88
  return asyncio.run(async_analyze())
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  # Streamlit app
91
  def main():
92
  st.title("CV Analyzer")
93
 
94
+ uploaded_file = st.file_uploader("Choose a CV file", type=["png", "jpg", "jpeg", "pdf"])
95
 
96
  if uploaded_file is not None:
97
  cv_content = read_file_content(uploaded_file)
98
  if cv_content:
99
+ st.text_area("Extracted CV Content", cv_content[:1000] + "..." if len(cv_content) > 1000 else cv_content, height=200)
100
 
101
  if st.button("Analyze CV"):
102
  with st.spinner("Analyzing CV..."):