Datasets:
Update OCW.py
Browse files
OCW.py
CHANGED
|
@@ -39,15 +39,19 @@ _HOMEPAGE_URL = "https://github.com/TaatiTeam/OCW/"
|
|
| 39 |
|
| 40 |
_LICENSE = "MIT"
|
| 41 |
|
| 42 |
-
_BASE_URL = "https://
|
| 43 |
_URLS = {
|
| 44 |
-
"ocw_train": _BASE_URL + "train.json",
|
| 45 |
-
"ocw_validation": _BASE_URL + "validation.json",
|
| 46 |
-
"ocw_test": _BASE_URL + "test.json",
|
| 47 |
-
"ocw_randomized_test": _BASE_URL + "easy_test_randomized.json",
|
| 48 |
-
"ocw_wordnet_train": _BASE_URL + "easy_train_wordnet.json",
|
| 49 |
-
"ocw_wordnet_validation": _BASE_URL + "easy_validation_wordnet.json",
|
| 50 |
-
"ocw_wordnet_test": _BASE_URL + "easy_test_wordnet.json"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
|
| 53 |
|
|
@@ -141,23 +145,32 @@ class OCW(datasets.GeneratorBasedBuilder):
|
|
| 141 |
)
|
| 142 |
|
| 143 |
def _split_generators(self, dl_manager):
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
else:
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
validation_path = dl_manager.download_and_extract(validation_url)
|
| 155 |
-
test_path = dl_manager.download_and_extract(test_url)
|
| 156 |
|
| 157 |
return [
|
| 158 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath":
|
| 159 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath":
|
| 160 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath":
|
| 161 |
]
|
| 162 |
|
| 163 |
|
|
|
|
| 39 |
|
| 40 |
_LICENSE = "MIT"
|
| 41 |
|
| 42 |
+
_BASE_URL = "https://www.cs.toronto.edu/~taati/OCW/"
|
| 43 |
_URLS = {
|
| 44 |
+
# "ocw_train": _BASE_URL + "train.json",
|
| 45 |
+
# "ocw_validation": _BASE_URL + "validation.json",
|
| 46 |
+
# "ocw_test": _BASE_URL + "test.json",
|
| 47 |
+
# "ocw_randomized_test": _BASE_URL + "easy_test_randomized.json",
|
| 48 |
+
# "ocw_wordnet_train": _BASE_URL + "easy_train_wordnet.json",
|
| 49 |
+
# "ocw_wordnet_validation": _BASE_URL + "easy_validation_wordnet.json",
|
| 50 |
+
# "ocw_wordnet_test": _BASE_URL + "easy_test_wordnet.json"
|
| 51 |
+
"ocw": _BASE_URL + "OCW.tar.gz",
|
| 52 |
+
"ocw_randomized": _BASE_URL + "OCW_randomized.tar.gz",
|
| 53 |
+
"ocw_wordnet": _BASE_URL + "OCW_wordnet.tar.gz"
|
| 54 |
+
|
| 55 |
}
|
| 56 |
|
| 57 |
|
|
|
|
| 145 |
)
|
| 146 |
|
| 147 |
def _split_generators(self, dl_manager):
|
| 148 |
+
url = _URLS[self.config.name]
|
| 149 |
+
if self.config.name == "ocw_randomized":
|
| 150 |
+
url = [url, _URLS[self.DEFAULT_CONFIG_NAME]]
|
| 151 |
+
path = dl_manager.download_and_extract(url)
|
| 152 |
+
if self.config.name == self.DEFAULT_CONFIG_NAME:
|
| 153 |
+
dir = 'dataset'
|
| 154 |
+
train_filepath = os.path.join(path, dir, 'train.json')
|
| 155 |
+
val_filepath = os.path.join(path, dir, 'validation.json')
|
| 156 |
+
test_filepath = os.path.join(path, dir, 'test.json')
|
| 157 |
+
elif self.config.name == "ocw_randomized":
|
| 158 |
+
# OCW-randomized only contains a test set, we load main OCW train/validation files
|
| 159 |
+
dir = 'OCW_randomized'
|
| 160 |
+
dir2 = 'dataset'
|
| 161 |
+
train_filepath = os.path.join(path[1], dir2, 'train.json')
|
| 162 |
+
val_filepath = os.path.join(path[1], dir2, 'validation.json')
|
| 163 |
+
test_filepath = os.path.join(path[0], dir, 'easy_test.json')
|
| 164 |
else:
|
| 165 |
+
dir = 'OCW_wordnet'
|
| 166 |
+
train_filepath = os.path.join(path, dir, 'easy_train_wordnet.json')
|
| 167 |
+
val_filepath = os.path.join(path, dir, 'easy_validation_wordnet.json')
|
| 168 |
+
test_filepath = os.path.join(path, dir, 'easy_test_wordnet.json')
|
|
|
|
|
|
|
| 169 |
|
| 170 |
return [
|
| 171 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_filepath}),
|
| 172 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": val_filepath}),
|
| 173 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_filepath}),
|
| 174 |
]
|
| 175 |
|
| 176 |
|