wics commited on
Commit
c803c96
·
1 Parent(s): ae08190

Update NCR.py

Browse files
Files changed (1) hide show
  1. NCR.py +13 -12
NCR.py CHANGED
@@ -98,17 +98,18 @@ class NCR(datasets.GeneratorBasedBuilder):
98
 
99
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
100
  def _generate_examples(self, filepath, split):
101
- print(filepath)
102
  with open(filepath, encoding="utf-8") as f:
103
  data = json.loads(f.read())
104
- questions = data["Questions"]
105
- for i in range(len(questions)):
106
- question = questions[i]
107
-
108
- yield f"{i}", {
109
- "example_id": data["Id"],
110
- "article": data["Content"],
111
- "question": question["Question"],
112
- "answer": question["Answer"],
113
- "options": question["Choices"],
114
- }
 
 
98
 
99
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
100
  def _generate_examples(self, filepath, split):
101
+
102
  with open(filepath, encoding="utf-8") as f:
103
  data = json.loads(f.read())
104
+ for article_idx,single_data in enumerate(data):
105
+ questions = single_data["Questions"]
106
+ for i in range(len(questions)):
107
+ question = questions[i]
108
+
109
+ yield f"{article_idx}_{i}", {
110
+ "example_id": single_data["Id"],
111
+ "article": single_data["Content"],
112
+ "question": question["Question"],
113
+ "answer": question["Answer"],
114
+ "options": question["Choices"],
115
+ }