FD900 commited on
Commit
c7215e2
·
verified ·
1 Parent(s): 0bf6784

Update questions.py

Browse files
Files changed (1) hide show
  1. questions.py +8 -11
questions.py CHANGED
@@ -1,22 +1,19 @@
1
  import json
2
- import os
3
 
4
- if os.path.exists("metadata.jsonl") and not os.path.exists("metadata_fixed.jsonl"):
5
- with open("metadata.jsonl", "r", encoding="utf-8") as infile, open("metadata_fixed.jsonl", "w", encoding="utf-8") as outfile:
6
- for line in infile:
7
- obj = json.loads(line)
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("metadata_fixed.jsonl", "r", encoding="utf-8") as f:
14
  questions = [json.loads(line) for line in f]
15
- print(f"✅ [questions.py] Loaded {len(questions)} questions from metadata_fixed.jsonl")
16
  return questions
17
  except FileNotFoundError:
18
- print("❌ metadata_fixed.jsonl not found.")
19
  return []
20
  except json.JSONDecodeError as e:
21
- print(f"❌ Failed to parse metadata_fixed.jsonl: {e}")
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 []