Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -151,15 +151,26 @@ def answer_matching(text):
|
|
151 |
return letters[0].upper() if len(letters) == 1 else random.choice(['A', 'B', 'C', 'D'])
|
152 |
|
153 |
|
154 |
-
def evaluate_uploaded_json(
|
|
|
|
|
|
|
|
|
|
|
155 |
print(f"Model Name: {model_name}")
|
156 |
print(f"Uploaded File: {user_file}")
|
157 |
|
158 |
id_answer_mapping = load_id_answer_mapping()
|
159 |
|
|
|
|
|
|
|
|
|
160 |
with open(user_file, "r", encoding="utf-8") as f:
|
161 |
user_data = json.load(f)
|
162 |
|
|
|
|
|
163 |
correct = 0
|
164 |
total = 0
|
165 |
|
@@ -170,7 +181,7 @@ def evaluate_uploaded_json(user_file, model_name):
|
|
170 |
question_id = item["id"]
|
171 |
raw_user_answer = item.get("model_answer", "")
|
172 |
user_answer = answer_matching(raw_user_answer)
|
173 |
-
question_class =
|
174 |
|
175 |
class_total[question_class] += 1
|
176 |
total += 1
|
|
|
151 |
return letters[0].upper() if len(letters) == 1 else random.choice(['A', 'B', 'C', 'D'])
|
152 |
|
153 |
|
154 |
+
def evaluate_uploaded_json(
|
155 |
+
user_file: str,
|
156 |
+
model_name: str,
|
157 |
+
multi_choice_file: str = "multi_choice.json",
|
158 |
+
):
|
159 |
+
|
160 |
print(f"Model Name: {model_name}")
|
161 |
print(f"Uploaded File: {user_file}")
|
162 |
|
163 |
id_answer_mapping = load_id_answer_mapping()
|
164 |
|
165 |
+
with open(multi_choice_file, "r", encoding="utf-8") as f:
|
166 |
+
mc_data = json.load(f)
|
167 |
+
id_class_mapping = {q["id"]: q["class"] for q in mc_data}
|
168 |
+
|
169 |
with open(user_file, "r", encoding="utf-8") as f:
|
170 |
user_data = json.load(f)
|
171 |
|
172 |
+
|
173 |
+
|
174 |
correct = 0
|
175 |
total = 0
|
176 |
|
|
|
181 |
question_id = item["id"]
|
182 |
raw_user_answer = item.get("model_answer", "")
|
183 |
user_answer = answer_matching(raw_user_answer)
|
184 |
+
question_class = id_class_mapping.get(question_id, "Unknown")
|
185 |
|
186 |
class_total[question_class] += 1
|
187 |
total += 1
|