Spaces:
Runtime error
Runtime error
Update app.py
Browse files369 unmodified lines37037137237337437537636 unmodified lines4134144154164174184194204214224233 unmodified lines4274284294304314324334344359 unmodified lines44544644744844945049 unmodified lines500501502503504505506369 unmodified linesparsed_data['student_info']['year_of_graduation'] = yog_match.group(1)# Improved GPA extraction with more flexible patternsgpa_matches = re.findall(r"(?:UNWEIGHTED|WEIGHTED)\s*GPA\s*([\d.]+)", text, re.IGNORECASE)if len(gpa_matches) >= 1:parsed_data['student_info']['unweighted_gpa'] = float(gpa_matches[0])if len(gpa_matches) >= 2:36 unmodified lines}# Extract assessments with more flexible patternassess_pattern = re.compile(r"Z-ASSESSMENT:\s*(.*?)\s*\|\s*(.*?)\s*\|\s*(\w+)\s*\|\s*(\d+)\s*%", re.IGNORECASE)for match in assess_pattern.finditer(text):name = f"Assessment: {match.group(1).strip()}"status = match.group(3).strip()parsed_data['assessments'][name] = status# Handle other Z itemsfor z_item in ["Community Service Hours", "GPA"]:3 unmodified linesparsed_data['assessments'][z_item] = status# Extract course history with more robust patterncourse_history_section = re.search(r"REQUIREMENT.*?SCHOOL YEAR.*?GRADELV1.*?CRSNUM.*?DESCRIPTION.*?TERM.*?DSTNUMBER.*?FG.*?INCL.*?CREDITS(.*?)(?:\n\s*\n|$)", text, re.DOTALL | re.IGNORECASE)if course_history_section:course_lines = [line.strip() for line in course_history_section.group(1).split('\n') if line.strip()]for line in course_lines:parts = [part.strip() for part in line.split('|')]if len(parts) >= 9:9 unmodified lines'included': parts[8] if len(parts) > 8 else "",'credits': parts[9] if len(parts) > 9 else "0"}parsed_data['course_history'].append(course)return parsed_data49 unmodified lines# ========== ENHANCED ANALYSIS FUNCTIONS ==========def analyze_gpa(parsed_data: Dict) -> str:try:gpa = float(parsed_data['student_info'].get('weighted_gpa', 0))if gpa >= 4.5:return "๐ Excellent GPA! You're in the top tier of students."elif gpa >= 3.5:369 unmodified lines37037137237337437537636 unmodified lines4134144154164174184194204214224234243 unmodified lines4284294304314324334344354369 unmodified lines44644744844945045145245345449 unmodified lines504505506507508509510369 unmodified linesparsed_data['student_info']['year_of_graduation'] = yog_match.group(1)# Improved GPA extraction with more flexible patternsgpa_matches = re.findall(r"(?:UN.?WEIGHTED|WEIGHTED)\s*GPA\s*([\d.]+)", text, re.IGNORECASE)if len(gpa_matches) >= 1:parsed_data['student_info']['unweighted_gpa'] = float(gpa_matches[0])if len(gpa_matches) >= 2:36 unmodified lines}# Extract assessments with more flexible patternassess_pattern = re.compile(r"Z-([^\|]+)\s*\|\s*([^\|]*)\s*\|\s*([^\|]*)\s*\|\s*([^\|]*)\s*%", re.IGNORECASE)for match in assess_pattern.finditer(text):name = f"Assessment: {match.group(1).strip()}"status = match.group(3).strip() if match.group(3) else ""if status:parsed_data['assessments'][name] = status# Handle other Z itemsfor z_item in ["Community Service Hours", "GPA"]:3 unmodified linesparsed_data['assessments'][z_item] = status# Extract course history with more robust patterncourse_history_section = re.search(r"Requirement.*?School Year.*?GradeLv1.*?CrsNum.*?Description.*?Term.*?DstNumber.*?FG.*?Incl.*?Credits(.*?)(?:\n\s*\n|$)", text, re.DOTALL | re.IGNORECASE)if course_history_section:course_lines = [line.strip() for line in course_history_section.group(1).split('\n') if line.strip() and '|' in line]for line in course_lines:parts = [part.strip() for part in line.split('|')]if len(parts) >= 9:9 unmodified lines'included': parts[8] if len(parts) > 8 else "",'credits': parts[9] if len(parts) > 9 else "0"}# Handle "inProgress" creditsif "inProgress" in course['credits'].lower():course['credits'] = "0"parsed_data['course_history'].append(course)return parsed_data49 unmodified lines# ========== ENHANCED ANALYSIS FUNCTIONS ==========def analyze_gpa(parsed_data: Dict) -> str:try:gpa = float(parsed_data.get('student_info', {}).get('weighted_gpa', 0))if gpa >= 4.5:return "๐ Excellent GPA! You're in the top tier of students."elif gpa >= 3.5:
app.py+11-7