Severine commited on
Commit
9b4758c
1 Parent(s): e57a100
Files changed (1) hide show
  1. SuperLim.py +16 -16
SuperLim.py CHANGED
@@ -19,6 +19,7 @@
19
  import json
20
  import os
21
  import datasets
 
22
 
23
  _CITATION = """\
24
  """
@@ -247,19 +248,18 @@ class SuperLim(datasets.GeneratorBasedBuilder):
247
  def _generate_examples(self, filepath, split):
248
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
249
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
250
- with open(filepath, encoding="utf-8") as f:
251
- for key, row in enumerate(f):
252
- data = json.loads(row)
253
- if self.config.name == "dalaj":
254
- # Yields examples as (key, example) tuples
255
- yield key, {
256
- "original sentence": data["original sentence"],
257
- "correct sentence": data["corrected sentence"],
258
- }
259
- else:
260
- yield key, {
261
- "sentence": data["sentence"],
262
- "option2": data["option2"],
263
- "second_domain_answer": "" if split == "test" else data["second_domain_answer"],
264
- }
265
-
 
19
  import json
20
  import os
21
  import datasets
22
+ import pandas as pd
23
 
24
  _CITATION = """\
25
  """
 
248
  def _generate_examples(self, filepath, split):
249
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
250
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
251
+ df = pd.read_csv(filepath)
252
+ for key, row in df.iterrows():
253
+ if self.config.name == "dalaj":
254
+ # Yields examples as (key, example) tuples
255
+ yield key, {
256
+ "original sentence": row["original sentence"],
257
+ "corrected sentence": row["corrected sentence"],
258
+ }
259
+ else:
260
+ yield key, {
261
+ "sentence": data["sentence"],
262
+ "option2": data["option2"],
263
+ "second_domain_answer": "" if split == "test" else data["second_domain_answer"],
264
+ }
265
+