File size: 2,473 Bytes
c924c3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f140f1f
 
c924c3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f140f1f
c924c3e
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from transcriber import transcribe_pdf
from evaluator import eval_flow
import json
import os

def flow(student_pdf_path: str,
          standard_pdf_path:str,
          save_dict: bool,
          student_dict_path: str,
          standard_dict_path: str,
          output_pdf_path: str):
    



    # create new interim_files folder if multiple instances of the flow are run

    # Transcribe the student's PDF response
    print("Transcribing the student's response")
    student_resp = transcribe_pdf(student_pdf_path, "interim_files_student", save_dict, student_dict_path)
    print("--------------------------------------------")

    # Transcribe the standard answer key PDF
    print("Transcribing the standard answer key")
    standard_key = transcribe_pdf(standard_pdf_path, "interim_files_standard", save_dict, standard_dict_path)
    print("--------------------------------------------")

    # # comment if running full flow
    # # when testing the evaluator only
    # student_resp = json.load(open(student_dict_path, "r"))
    # standard_key = json.load(open(standard_dict_path, "r"))


    # Evaluate the student's response and generate a report
    print("Evaluating the student's response")
    eval_flow(student_resp, standard_key, output_pdf_path)

    print("Flow completed successfully!")
    print("--------------------------------------------")

    # remove the files in the interim_files folder
    print("Clearing interim files folder")
    for file in os.listdir("interim_files_student"):
        file_path = os.path.join("interim_files_student", file)
        os.remove(file_path)

    for file in os.listdir("interim_files_standard"):
        file_path = os.path.join("interim_files_standard", file)
        os.remove(file_path)



    return output_pdf_path


if __name__ == "__main__":
    # student_pdf_path = "examples/Chapter 1 - Indian Regulatory Framework Student Answer Key  (1).pdf"
    # standard_pdf_path = "examples/Chapter 1 Indian Regulatory Frame Work Standard Question And Answer Key (2).pdf"
    
    student_pdf_path = "examples/ca inter chapter - amalgamation student answer.pdf"
    standard_pdf_path = "examples/ca inter chapter - amalgamation.pdf"

    save_dict = True
    student_dict_path = "student_response.json"
    standard_dict_path = "standard_key.json"
    output_pdf_path = "output_report.pdf"

    flow(student_pdf_path, standard_pdf_path, save_dict, student_dict_path, standard_dict_path, output_pdf_path)