Datasets:

Languages:
Spanish
License:
joanllop commited on
Commit
fe48c03
1 Parent(s): 68e0e09

Update wnli.py

Browse files
Files changed (1) hide show
  1. wnli.py +17 -19
wnli.py CHANGED
@@ -84,24 +84,22 @@ class Winograd(datasets.GeneratorBasedBuilder):
84
  def _generate_examples(self, filepath):
85
  """This function returns the examples in the raw (text) form."""
86
  logger.info("generating examples from = %s", filepath)
87
- with open(filepath, encoding="utf-8") as f:
88
- header = next(f)
89
- lines = f.readlines()
90
- process_label = {'0': "not_entailment", '1': "entailment"}
91
- for id_, row in enumerate(lines):
92
- if "label" in header:
93
- ref, sentence1, sentence2, score = row[:-1].split('\t')
94
- yield id_, {
95
- "sentence1": sentence1,
96
- "sentence2": sentence2,
97
- "label": process_label[score],
98
- }
99
- else:
100
- ref, sentence1, sentence2 = row.split('\t')
101
- yield id_, {
102
- "sentence1": sentence1,
103
- "sentence2": sentence2,
104
- "label": -1,
105
- }
106
 
107
 
 
84
  def _generate_examples(self, filepath):
85
  """This function returns the examples in the raw (text) form."""
86
  logger.info("generating examples from = %s", filepath)
87
+ df = pd.read_csv(filepath, sep='\t')
88
+ header = df.keys()
89
+ process_label = {0: "not_entailment", 1: "entailment"}
90
+ if "label" in header:
91
+ for id_, (ref, sentence1, sentence2, score) in df.iterrows():
92
+ yield id_, {
93
+ "sentence1": sentence1,
94
+ "sentence2": sentence2,
95
+ "label": process_label[score],
96
+ }
97
+ else:
98
+ for id_, (ref, sentence1, sentence2) in df.iterrows():
99
+ yield id_, {
100
+ "sentence1": sentence1,
101
+ "sentence2": sentence2,
102
+ "label": -1,
103
+ }
 
 
104
 
105