Dannyar608 commited on
Commit
e0ad8bb
Β·
verified Β·
1 Parent(s): 33513a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -370,7 +370,7 @@ class TranscriptParser:
370
  parsed_data['student_info']['year_of_graduation'] = yog_match.group(1)
371
 
372
  # Improved GPA extraction with more flexible patterns
373
- gpa_matches = re.findall(r"(?:UNWEIGHTED|WEIGHTED)\s*GPA\s*([\d.]+)", text, re.IGNORECASE)
374
  if len(gpa_matches) >= 1:
375
  parsed_data['student_info']['unweighted_gpa'] = float(gpa_matches[0])
376
  if len(gpa_matches) >= 2:
@@ -413,11 +413,12 @@ class TranscriptParser:
413
  }
414
 
415
  # Extract assessments with more flexible pattern
416
- assess_pattern = re.compile(r"Z-ASSESSMENT:\s*(.*?)\s*\|\s*(.*?)\s*\|\s*(\w+)\s*\|\s*(\d+)\s*%", re.IGNORECASE)
417
  for match in assess_pattern.finditer(text):
418
  name = f"Assessment: {match.group(1).strip()}"
419
- status = match.group(3).strip()
420
- parsed_data['assessments'][name] = status
 
421
 
422
  # Handle other Z items
423
  for z_item in ["Community Service Hours", "GPA"]:
@@ -427,9 +428,9 @@ class TranscriptParser:
427
  parsed_data['assessments'][z_item] = status
428
 
429
  # Extract course history with more robust pattern
430
- course_history_section = re.search(r"REQUIREMENT.*?SCHOOL YEAR.*?GRADELV1.*?CRSNUM.*?DESCRIPTION.*?TERM.*?DSTNUMBER.*?FG.*?INCL.*?CREDITS(.*?)(?:\n\s*\n|$)", text, re.DOTALL | re.IGNORECASE)
431
  if course_history_section:
432
- course_lines = [line.strip() for line in course_history_section.group(1).split('\n') if line.strip()]
433
  for line in course_lines:
434
  parts = [part.strip() for part in line.split('|')]
435
  if len(parts) >= 9:
@@ -445,6 +446,9 @@ class TranscriptParser:
445
  'included': parts[8] if len(parts) > 8 else "",
446
  'credits': parts[9] if len(parts) > 9 else "0"
447
  }
 
 
 
448
  parsed_data['course_history'].append(course)
449
 
450
  return parsed_data
@@ -500,7 +504,7 @@ class TranscriptParser:
500
  # ========== ENHANCED ANALYSIS FUNCTIONS ==========
501
  def analyze_gpa(parsed_data: Dict) -> str:
502
  try:
503
- gpa = float(parsed_data['student_info'].get('weighted_gpa', 0))
504
  if gpa >= 4.5:
505
  return "🌟 Excellent GPA! You're in the top tier of students."
506
  elif gpa >= 3.5:
 
370
  parsed_data['student_info']['year_of_graduation'] = yog_match.group(1)
371
 
372
  # Improved GPA extraction with more flexible patterns
373
+ gpa_matches = re.findall(r"(?:UN.?WEIGHTED|WEIGHTED)\s*GPA\s*([\d.]+)", text, re.IGNORECASE)
374
  if len(gpa_matches) >= 1:
375
  parsed_data['student_info']['unweighted_gpa'] = float(gpa_matches[0])
376
  if len(gpa_matches) >= 2:
 
413
  }
414
 
415
  # Extract assessments with more flexible pattern
416
+ assess_pattern = re.compile(r"Z-([^\|]+)\s*\|\s*([^\|]*)\s*\|\s*([^\|]*)\s*\|\s*([^\|]*)\s*%", re.IGNORECASE)
417
  for match in assess_pattern.finditer(text):
418
  name = f"Assessment: {match.group(1).strip()}"
419
+ status = match.group(3).strip() if match.group(3) else ""
420
+ if status:
421
+ parsed_data['assessments'][name] = status
422
 
423
  # Handle other Z items
424
  for z_item in ["Community Service Hours", "GPA"]:
 
428
  parsed_data['assessments'][z_item] = status
429
 
430
  # Extract course history with more robust pattern
431
+ course_history_section = re.search(r"Requirement.*?School Year.*?GradeLv1.*?CrsNum.*?Description.*?Term.*?DstNumber.*?FG.*?Incl.*?Credits(.*?)(?:\n\s*\n|$)", text, re.DOTALL | re.IGNORECASE)
432
  if course_history_section:
433
+ course_lines = [line.strip() for line in course_history_section.group(1).split('\n') if line.strip() and '|' in line]
434
  for line in course_lines:
435
  parts = [part.strip() for part in line.split('|')]
436
  if len(parts) >= 9:
 
446
  'included': parts[8] if len(parts) > 8 else "",
447
  'credits': parts[9] if len(parts) > 9 else "0"
448
  }
449
+ # Handle "inProgress" credits
450
+ if "inProgress" in course['credits'].lower():
451
+ course['credits'] = "0"
452
  parsed_data['course_history'].append(course)
453
 
454
  return parsed_data
 
504
  # ========== ENHANCED ANALYSIS FUNCTIONS ==========
505
  def analyze_gpa(parsed_data: Dict) -> str:
506
  try:
507
+ gpa = float(parsed_data.get('student_info', {}).get('weighted_gpa', 0))
508
  if gpa >= 4.5:
509
  return "🌟 Excellent GPA! You're in the top tier of students."
510
  elif gpa >= 3.5: