EC2 Default User commited on
Commit
6aeb551
·
1 Parent(s): f43d5c8

Add generator

Browse files
Files changed (1) hide show
  1. oas-paired-sequence-data.py +19 -27
oas-paired-sequence-data.py CHANGED
@@ -39,10 +39,10 @@ _HOMEPAGE = "https://opig.stats.ox.ac.uk/webapps/oas/"
39
  _LICENSE = "cc-by-4.0"
40
 
41
  _URLS = {
42
- "human": "data/human/*.parquet",
43
- "rat_SD": "data/rat_SD/*.parquet",
44
- "mouse_BALB_c": "data/mouse_BALB_c/*.parquet",
45
- "mouse_C57BL_6": "data/mouse_C57BL_6/*.parquet",
46
  }
47
 
48
  _FEATURES = datasets.Features(
@@ -121,7 +121,8 @@ class OasPairedSequenceData(datasets.GeneratorBasedBuilder):
121
  name=datasets.Split.TRAIN,
122
  # These kwargs will be passed to _generate_examples
123
  gen_kwargs={
124
- "filepath": os.path.join(data_dir, "train.jsonl"),
 
125
  "split": "train",
126
  },
127
  ),
@@ -143,26 +144,17 @@ class OasPairedSequenceData(datasets.GeneratorBasedBuilder):
143
  # ),
144
  ]
145
 
146
- # # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
147
- # def _generate_examples(self, filepath, split):
148
- # # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
149
- # # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
150
- # with open(filepath, encoding="utf-8") as f:
151
- # for key, row in enumerate(f):
152
- # data = json.loads(row)
153
- # if self.config.name == "first_domain":
154
- # # Yields examples as (key, example) tuples
155
- # yield key, {
156
- # "sentence": data["sentence"],
157
- # "option1": data["option1"],
158
- # "answer": "" if split == "test" else data["answer"],
159
- # }
160
- # else:
161
- # yield key, {
162
- # "sentence": data["sentence"],
163
- # "option2": data["option2"],
164
- # "second_domain_answer": ""
165
- # if split == "test"
166
- # else data["second_domain_answer"],
167
- # }
168
 
 
39
  _LICENSE = "cc-by-4.0"
40
 
41
  _URLS = {
42
+ "human": "data/human",
43
+ "rat_SD": "data/rat_SD",
44
+ "mouse_BALB_c": "data/mouse_BALB_c",
45
+ "mouse_C57BL_6": "data/mouse_C57BL_6",
46
  }
47
 
48
  _FEATURES = datasets.Features(
 
121
  name=datasets.Split.TRAIN,
122
  # These kwargs will be passed to _generate_examples
123
  gen_kwargs={
124
+ # "filepath": os.path.join(data_dir, "train.jsonl"),
125
+ "filepath": data_dir,
126
  "split": "train",
127
  },
128
  ),
 
144
  # ),
145
  ]
146
 
147
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
148
+ def _generate_examples(self, filepath, split):
149
+ # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
150
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
151
+ with open(filepath, encoding="utf-8") as f:
152
+ for key, row in enumerate(f):
153
+ data = json.loads(row)
154
+ yield key, data
155
+ # yield key, {
156
+ # "sentence": data["sentence"],
157
+ # "option2": data["option2"],
158
+ # "second_domain_answer": ""
159
+ # }
 
 
 
 
 
 
 
 
 
160