muhammadravi251001 commited on
Commit
2e1974b
·
verified ·
1 Parent(s): d14561f

Update squadid-nli.py

Browse files
Files changed (1) hide show
  1. squadid-nli.py +7 -8
squadid-nli.py CHANGED
@@ -16,7 +16,7 @@
16
 
17
 
18
  import json
19
-
20
  import datasets
21
 
22
 
@@ -99,12 +99,11 @@ class SQuADIDNLI(datasets.GeneratorBasedBuilder):
99
 
100
  def _generate_examples(self, filepath):
101
  """Yields examples."""
102
-
103
- with open(filepath, encoding="utf-8") as jsonl_file:
104
- for id_, row in enumerate(jsonl_file):
105
- row_jsonl = json.loads(row)
106
  yield id_, {
107
- "premise": row_jsonl["premise"],
108
- "hypothesis": row_jsonl["hypothesis"],
109
- "label": {"e": "entailment", "n": "neutral", "c": "contradiction"}[row_jsonl["label"]],
110
  }
 
16
 
17
 
18
  import json
19
+ import csv
20
  import datasets
21
 
22
 
 
99
 
100
  def _generate_examples(self, filepath):
101
  """Yields examples."""
102
+ with open(filepath, encoding="utf-8") as csv_file:
103
+ csv_reader = csv.DictReader(csv_file)
104
+ for id_, row in enumerate(csv_reader):
 
105
  yield id_, {
106
+ "premise": row["premise"],
107
+ "hypothesis": row["hypothesis"],
108
+ "label": row["label"]
109
  }