Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -341,19 +341,30 @@ class TranscriptParser:
|
|
341 |
text, re.DOTALL
|
342 |
)
|
343 |
|
|
|
344 |
if student_match:
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
|
356 |
# Extract requirements with better table parsing
|
|
|
357 |
req_section = re.search(
|
358 |
r"Code\s*Description\s*Required\s*Waived\s*Completed\s*Status(.*?)Total\s*[\d.]+\s*[\d.]+\s*[\d.]+\s*[\d.]+%",
|
359 |
text, re.DOTALL
|
@@ -366,16 +377,21 @@ class TranscriptParser:
|
|
366 |
)
|
367 |
|
368 |
for match in req_matches:
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
|
|
|
|
|
|
|
|
377 |
|
378 |
# Extract course history with more flexible parsing
|
|
|
379 |
course_section = re.search(
|
380 |
r"Requirement\s*School Year\s*GradeLv1\s*CrsNu m\s*Description(.*?)(?=Legend for Incl:|$)",
|
381 |
text, re.DOTALL
|
@@ -388,18 +404,22 @@ class TranscriptParser:
|
|
388 |
)
|
389 |
|
390 |
for match in course_matches:
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
|
|
|
|
|
|
|
|
403 |
|
404 |
# Identify current courses
|
405 |
self._extract_current_courses()
|
|
|
341 |
text, re.DOTALL
|
342 |
)
|
343 |
|
344 |
+
self.student_data = {}
|
345 |
if student_match:
|
346 |
+
try:
|
347 |
+
self.student_data = {
|
348 |
+
"id": student_match.group(1),
|
349 |
+
"name": student_match.group(2).replace(",", ", "),
|
350 |
+
"current_grade": student_match.group(3),
|
351 |
+
"graduation_year": student_match.group(4),
|
352 |
+
"unweighted_gpa": float(student_match.group(5)),
|
353 |
+
"weighted_gpa": float(student_match.group(6)),
|
354 |
+
"total_credits": float(student_match.group(7)),
|
355 |
+
"community_service_hours": int(student_match.group(8))
|
356 |
+
}
|
357 |
+
except (IndexError, AttributeError) as e:
|
358 |
+
logging.warning(f"Error extracting student info: {str(e)}")
|
359 |
+
# Try to get at least the name and ID
|
360 |
+
if student_match.group(1) and student_match.group(2):
|
361 |
+
self.student_data = {
|
362 |
+
"id": student_match.group(1),
|
363 |
+
"name": student_match.group(2).replace(",", ", ")
|
364 |
+
}
|
365 |
|
366 |
# Extract requirements with better table parsing
|
367 |
+
self.requirements = {}
|
368 |
req_section = re.search(
|
369 |
r"Code\s*Description\s*Required\s*Waived\s*Completed\s*Status(.*?)Total\s*[\d.]+\s*[\d.]+\s*[\d.]+\s*[\d.]+%",
|
370 |
text, re.DOTALL
|
|
|
377 |
)
|
378 |
|
379 |
for match in req_matches:
|
380 |
+
try:
|
381 |
+
req_code = match.group(1).strip()
|
382 |
+
self.requirements[req_code] = {
|
383 |
+
"description": match.group(2).strip(),
|
384 |
+
"required": float(match.group(3)),
|
385 |
+
"waived": float(match.group(4)),
|
386 |
+
"completed": float(match.group(5)),
|
387 |
+
"status": f"{match.group(6)}%"
|
388 |
+
}
|
389 |
+
except (IndexError, AttributeError) as e:
|
390 |
+
logging.warning(f"Skipping requirement due to error: {str(e)}")
|
391 |
+
continue
|
392 |
|
393 |
# Extract course history with more flexible parsing
|
394 |
+
self.course_history = []
|
395 |
course_section = re.search(
|
396 |
r"Requirement\s*School Year\s*GradeLv1\s*CrsNu m\s*Description(.*?)(?=Legend for Incl:|$)",
|
397 |
text, re.DOTALL
|
|
|
404 |
)
|
405 |
|
406 |
for match in course_matches:
|
407 |
+
try:
|
408 |
+
self.course_history.append({
|
409 |
+
"requirement_category": match.group(1).strip(),
|
410 |
+
"school_year": match.group(2),
|
411 |
+
"grade_level": match.group(3),
|
412 |
+
"course_code": match.group(4),
|
413 |
+
"description": match.group(5).strip(),
|
414 |
+
"term": match.group(6),
|
415 |
+
"district_number": match.group(7),
|
416 |
+
"grade": match.group(8),
|
417 |
+
"inclusion_status": match.group(9),
|
418 |
+
"credits": match.group(10)
|
419 |
+
})
|
420 |
+
except (IndexError, AttributeError) as e:
|
421 |
+
logging.warning(f"Skipping course due to error: {str(e)}")
|
422 |
+
continue
|
423 |
|
424 |
# Identify current courses
|
425 |
self._extract_current_courses()
|