Athuz commited on
Commit
9ef702e
·
verified ·
1 Parent(s): 9bb5640

will be back soon

Browse files
Files changed (1) hide show
  1. app.py +10 -16
app.py CHANGED
@@ -760,6 +760,7 @@ def extract_marks_from_grading(grading_text):
760
  def extract_grading_summary_from_report(grading_text):
761
  """
762
  Extract the Examiner's Summary Report from grading text and return as DataFrame.
 
763
 
764
  Args:
765
  grading_text (str): Full grading report text
@@ -767,30 +768,23 @@ def extract_grading_summary_from_report(grading_text):
767
  Returns:
768
  pd.DataFrame: Summary table with columns [Question, Marks, Remark, Feedback]
769
  """
770
- import pandas as pd
771
-
772
  print("🔎 Extracting Examiner's Summary Report from grading text...")
773
 
774
- # Find the summary section
775
- summary_match = re.search(r"### Examiner's Summary Report(.*?)(?=\n\n\*\*Total:|$)", grading_text, re.DOTALL)
776
- if not summary_match:
777
- print("⚠️ No Examiner's Summary Report found")
778
- return pd.DataFrame(columns=["Question", "Marks", "Remark", "Feedback"])
779
 
780
- summary_text = summary_match.group(1)
781
 
782
- # Extract table rows
783
- row_pattern = re.compile(r"\|\s*(\d+(?:\.\w+)*)\s*\|\s*([\d/]+)\s*\|\s*([A-E])\s*\|\s*(.*?)\s*\|", re.DOTALL)
784
  rows = row_pattern.findall(summary_text)
785
 
786
- if not rows:
787
- print("⚠️ No table rows found in summary report")
788
- return pd.DataFrame(columns=["Question", "Marks", "Remark", "Feedback"])
789
-
790
  df = pd.DataFrame(rows, columns=["Question", "Marks", "Remark", "Feedback"])
791
 
792
- # Extract total
793
- total_pattern = re.search(r"\*\*Total:\s*(\d+/\d+)\*\*", grading_text)
794
  if total_pattern:
795
  df.loc[len(df)] = ["TOTAL", total_pattern.group(1), "", "Overall total score"]
796
 
 
760
  def extract_grading_summary_from_report(grading_text):
761
  """
762
  Extract the Examiner's Summary Report from grading text and return as DataFrame.
763
+ Uses the same approach as the provided example code.
764
 
765
  Args:
766
  grading_text (str): Full grading report text
 
768
  Returns:
769
  pd.DataFrame: Summary table with columns [Question, Marks, Remark, Feedback]
770
  """
 
 
771
  print("🔎 Extracting Examiner's Summary Report from grading text...")
772
 
773
+ # 1. Capture EVERYTHING after the header
774
+ summary_text = re.search(r"### Examiner's Summary Report(.*)", grading_text, re.DOTALL)
775
+ if not summary_text:
776
+ raise ValueError("Examiner's Summary Report not found")
 
777
 
778
+ summary_text = summary_text.group(1)
779
 
780
+ # 2. Extract table rows
781
+ row_pattern = re.compile(r"\|\s*(\d+)\s*\|\s*([\d/]+)\s*\|\s*([A-D])\s*\|\s*(.*?)\s*\|", re.DOTALL)
782
  rows = row_pattern.findall(summary_text)
783
 
 
 
 
 
784
  df = pd.DataFrame(rows, columns=["Question", "Marks", "Remark", "Feedback"])
785
 
786
+ # 3. Extract TOTAL directly from same block
787
+ total_pattern = re.search(r"Total:\s*(\d+/\d+)", summary_text)
788
  if total_pattern:
789
  df.loc[len(df)] = ["TOTAL", total_pattern.group(1), "", "Overall total score"]
790