Spaces:
Sleeping
Sleeping
Update questions.py
Browse files- questions.py +8 -11
questions.py
CHANGED
|
@@ -1,22 +1,19 @@
|
|
| 1 |
import json
|
| 2 |
-
import os
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
obj["question"] = obj.pop("Question") # Rename the key
|
| 9 |
-
outfile.write(json.dumps(obj) + "\n")
|
| 10 |
|
| 11 |
def get_all_questions():
|
| 12 |
try:
|
| 13 |
-
with open("
|
| 14 |
questions = [json.loads(line) for line in f]
|
| 15 |
-
print(f"✅ [questions.py] Loaded {len(questions)} questions from
|
| 16 |
return questions
|
| 17 |
except FileNotFoundError:
|
| 18 |
-
print("❌
|
| 19 |
return []
|
| 20 |
except json.JSONDecodeError as e:
|
| 21 |
-
print(f"❌ Failed to parse
|
| 22 |
return []
|
|
|
|
| 1 |
import json
|
|
|
|
| 2 |
|
| 3 |
+
def fix_keys(obj):
|
| 4 |
+
if "Question" in obj:
|
| 5 |
+
obj["question"] = obj.pop("Question")
|
| 6 |
+
return obj
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def get_all_questions():
|
| 9 |
try:
|
| 10 |
+
with open("metadata.jsonl", "r", encoding="utf-8") as f:
|
| 11 |
questions = [json.loads(line) for line in f]
|
| 12 |
+
print(f"✅ [questions.py] Loaded {len(questions)} questions from metadata.jsonl")
|
| 13 |
return questions
|
| 14 |
except FileNotFoundError:
|
| 15 |
+
print("❌ metadata.jsonl not found.")
|
| 16 |
return []
|
| 17 |
except json.JSONDecodeError as e:
|
| 18 |
+
print(f"❌ Failed to parse metadata.jsonl: {e}")
|
| 19 |
return []
|