Datasets:

Modalities:
Text
Languages:
English
ArXiv:
Libraries:
Datasets
License:
neel-alex commited on
Commit
a3d1272
1 Parent(s): 8eae632

More bugfixes to get a working copy (squashed)

Browse files
Files changed (1) hide show
  1. raft.py +16 -9
raft.py CHANGED
@@ -50,8 +50,8 @@ _LICENSE = ""
50
  # This gets all folders within the directory named `data`
51
  DATA_DIRS = next(os.walk('data'))[1]
52
 
53
- _URLs = {s: {'train': f".data/{s}/train.csv",
54
- 'test': f".data/{s}/test_unlabeled.csv"} for s in DATA_DIRS}
55
 
56
 
57
  class Raft(datasets.GeneratorBasedBuilder):
@@ -73,18 +73,25 @@ class Raft(datasets.GeneratorBasedBuilder):
73
 
74
  # TODO: Load task jsons
75
 
76
- tasks = []
77
  for sd in DATA_DIRS:
78
  with open(os.path.join('data', sd, 'task.json')) as f:
79
  task_data = json.load(f)
80
- tasks.append(task_data)
81
 
82
- BUILDER_CONFIGS = [datasets.BuilderConfig(name=td['name'], version=VERSION,
83
- description=td['description']) for td in tasks]
 
 
 
 
 
84
 
85
  DEFAULT_CONFIG_NAME = "tai_safety_research" # It's not mandatory to have a default configuration. Just use one if it make sense.
86
 
87
  def _info(self):
 
 
88
  task = Raft.tasks[self.config.name]
89
  # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
90
  data_columns = {col_name: datasets.Value("string") for col_name in
@@ -92,7 +99,7 @@ class Raft(datasets.GeneratorBasedBuilder):
92
 
93
  label_columns = {}
94
  for label_name in task['label_columns']:
95
- labels = task['label_columns'][label_name]
96
  label_columns[label_name] = datasets.ClassLabel(len(labels), labels)
97
 
98
  # Merge dicts
@@ -152,5 +159,5 @@ class Raft(datasets.GeneratorBasedBuilder):
152
  if id_ == 0: # First row is column names
153
  continue
154
  if split == "test":
155
- row += [""] * num_labels
156
- return {name: value for name, value in zip(column_names, row)}
 
50
  # This gets all folders within the directory named `data`
51
  DATA_DIRS = next(os.walk('data'))[1]
52
 
53
+ _URLs = {s: {'train': f"data/{s}/train.csv",
54
+ 'test': f"data/{s}/test_unlabeled.csv"} for s in DATA_DIRS}
55
 
56
 
57
  class Raft(datasets.GeneratorBasedBuilder):
 
73
 
74
  # TODO: Load task jsons
75
 
76
+ tasks = {}
77
  for sd in DATA_DIRS:
78
  with open(os.path.join('data', sd, 'task.json')) as f:
79
  task_data = json.load(f)
80
+ tasks[sd] = task_data
81
 
82
+ BUILDER_CONFIGS = []
83
+ for key in tasks:
84
+ td = tasks[key]
85
+ name = td['name']
86
+ description = td['description']
87
+ BUILDER_CONFIGS.append(datasets.BuilderConfig(name=name, version=VERSION,
88
+ description=description))
89
 
90
  DEFAULT_CONFIG_NAME = "tai_safety_research" # It's not mandatory to have a default configuration. Just use one if it make sense.
91
 
92
  def _info(self):
93
+ DEFAULT_LABEL_NAME = "Unlabeled"
94
+
95
  task = Raft.tasks[self.config.name]
96
  # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
97
  data_columns = {col_name: datasets.Value("string") for col_name in
 
99
 
100
  label_columns = {}
101
  for label_name in task['label_columns']:
102
+ labels = ["Unlabeled"] + task['label_columns'][label_name]
103
  label_columns[label_name] = datasets.ClassLabel(len(labels), labels)
104
 
105
  # Merge dicts
 
159
  if id_ == 0: # First row is column names
160
  continue
161
  if split == "test":
162
+ row += ["Unlabeled"] * num_labels
163
+ yield id_, {name: value for name, value in zip(column_names, row)}