Datasets:

Languages:
Chinese
ArXiv:
License:
qian commited on
Commit
f861f8d
1 Parent(s): f28de68

Update T2Ranking.py

Browse files
Files changed (1) hide show
  1. T2Ranking.py +9 -3
T2Ranking.py CHANGED
@@ -17,6 +17,7 @@ import datasets
17
  import json
18
  from typing import List
19
  import pandas as pd
 
20
 
21
  _LICENSE = "http://www.apache.org/licenses/LICENSE-2.0"
22
  _HOMEPAGE='https://huggingface.co/datasets/THUIR/T2Ranking'
@@ -178,7 +179,12 @@ class T2Ranking(datasets.GeneratorBasedBuilder):
178
  return split_things
179
 
180
  def _generate_examples(self, filepath):
181
- data = pd.read_csv(filepath, sep='\t', quoting=3)
 
182
  keys = _FEATURES_DICT[self.config.name].keys()
183
- for idx in range(data.shape[0]):
184
- yield idx, {key: data[key][idx] for key in keys}
 
 
 
 
 
17
  import json
18
  from typing import List
19
  import pandas as pd
20
+ import csv
21
 
22
  _LICENSE = "http://www.apache.org/licenses/LICENSE-2.0"
23
  _HOMEPAGE='https://huggingface.co/datasets/THUIR/T2Ranking'
 
179
  return split_things
180
 
181
  def _generate_examples(self, filepath):
182
+ # data = pd.read_csv(filepath, sep='\t', quoting=3)
183
+ reader = csv.DictReader(filepath, delimiter='\t')
184
  keys = _FEATURES_DICT[self.config.name].keys()
185
+ idx = -1
186
+ for data in reader:
187
+ idx+=1
188
+ yield idx, {key: data[key] for key in keys}
189
+ # for idx in range(data.shape[0]):
190
+ # yield idx, {key: data[key][idx] for key in keys}