wics commited on
Commit
2ce688e
·
1 Parent(s): c856936

Update NCR.py

Browse files
Files changed (1) hide show
  1. NCR.py +17 -17
NCR.py CHANGED
@@ -97,20 +97,20 @@ class NCR(datasets.GeneratorBasedBuilder):
97
  ]
98
 
99
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
100
- def _generate_examples(self, train_test_or_eval, files):
101
- """Yields examples."""
102
- for file_idx, (path, f) in enumerate(files):
103
- if path.startswith(train_test_or_eval) and path.endswith(".txt"):
104
- data = json.loads(f.read().decode("utf-8"))
105
- questions = data["Questions"]
106
- for i in range(len(questions)):
107
- question = questions[i]
108
-
109
- yield f"{file_idx}_{i}", {
110
- "example_id": data["Id"],
111
- "article": data["Content"],
112
- "question": question["Question"],
113
- "answer": question["Answer"],
114
- "options": question["Choices"],
115
- }
116
-
 
97
  ]
98
 
99
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
100
+ def _generate_examples(self, filepath, split):
101
+ def normalize(text):
102
+ return text.replace(".", ". ").strip()
103
+
104
+ with open(filepath, encoding="utf-8") as f:
105
+ data = json.loads(f.read().decode("utf-8"))
106
+ questions = data["Questions"]
107
+ for i in range(len(questions)):
108
+ question = questions[i]
109
+
110
+ yield f"{i}", {
111
+ "example_id": data["Id"],
112
+ "article": data["Content"],
113
+ "question": question["Question"],
114
+ "answer": question["Answer"],
115
+ "options": question["Choices"],
116
+ }