File size: 1,058 Bytes
f4f1e28 |
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 |
from typing import List
import json
def get_question_by_id(l,question_id):
doc=None
for i in l:
if i['original_question']['question_id']==question_id:
doc=i
break
return doc
def get_question_ids_with_correctness(l) -> List[str]:
print("started")
results = []
for doc in l:
data = doc
question_id = data['original_question']['question_id']
correct_answer = data['original_question']['answer']
generated_answer = data['generated_result']['answer_key_vale']
correctness = "✅" if correct_answer == generated_answer else '📛'
results.append(f"{question_id} {correctness}")
return results
def init_json():
with open("./all_data.json") as f:
return json.load(f)
def update_depth(question_id,depth):
with open('all_data_json' ,'w') as f:
l=json.load(f)
for i in l:
if i['original_question']['question_id']==question_id:
i["max_depth"]=depth
break
f.write(l) |