nmd2k commited on
Commit
833778f
·
1 Parent(s): ee65ab9
Files changed (1) hide show
  1. testcm.py +14 -14
testcm.py CHANGED
@@ -93,17 +93,17 @@ class CodeMMLU(datasets.GeneratorBasedBuilder):
93
  def _generate_examples(self, data_path):
94
  """This function returns the examples in the raw (text) form."""
95
  if data_path.endswith(".jsonl"):
96
- lines = open(data_path, "r", encoding="utf-8").readlines()
97
- reader = [json.loads(line) for line in lines]
98
- for idx, data in enumerate(reader):
99
- return_dict = {
100
- "task_id": data['task_id'],
101
- "question": data['question'],
102
- "choices": data['choices'],
103
- }
104
-
105
- if "fill_in_the_middle" in data_path:
106
- return_dict['problem_description'] = data['problem_description']
107
-
108
- return_dict['answer'] = data['answer']
109
- yield idx, return_dict
 
93
  def _generate_examples(self, data_path):
94
  """This function returns the examples in the raw (text) form."""
95
  if data_path.endswith(".jsonl"):
96
+ with open(data_path, "r", encoding="utf-8") as f:
97
+ for idx, line in enumerate(f):
98
+ data = json.loads(line)
99
+ return_dict = {
100
+ "task_id": data['task_id'],
101
+ "question": data['question'],
102
+ "choices": data['choices'],
103
+ }
104
+
105
+ if "fill_in_the_middle" in data_path:
106
+ return_dict['problem_description'] = data['problem_description']
107
+
108
+ return_dict['answer'] = data['answer']
109
+ yield idx, return_dict