Commit
•
28f9970
1
Parent(s):
18f251f
Optimize code to perform less calls to filesystem
Browse files
twadrl.py
CHANGED
@@ -108,24 +108,19 @@ class TwADRL(datasets.GeneratorBasedBuilder):
|
|
108 |
dl_dir = dl_manager.download_and_extract(_URLs)
|
109 |
dataset_dir = os.path.join(dl_dir, "datasets", "TwADR-L")
|
110 |
# dataset supports k-folds
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
datasets.
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
name=split_id,
|
125 |
-
gen_kwargs={"filepath": fold_filepath, "split_id": split_id},
|
126 |
-
)
|
127 |
-
)
|
128 |
-
return splits
|
129 |
|
130 |
def _generate_examples(self, filepath, split_id):
|
131 |
with open(filepath, "r", encoding="latin-1") as f:
|
|
|
108 |
dl_dir = dl_manager.download_and_extract(_URLs)
|
109 |
dataset_dir = os.path.join(dl_dir, "datasets", "TwADR-L")
|
110 |
# dataset supports k-folds
|
111 |
+
splits_names = ["train", "validation", "test"]
|
112 |
+
fold_ids = range(10)
|
113 |
+
return [
|
114 |
+
datasets.SplitGenerator(
|
115 |
+
name=f"{split_name}_{fold_id}",
|
116 |
+
gen_kwargs={
|
117 |
+
"filepath": os.path.join(dataset_dir, f"TwADR-L.fold-{fold_id}.{split_name}.txt"),
|
118 |
+
"split_id": f"{split_name}_{fold_id}",
|
119 |
+
},
|
120 |
+
)
|
121 |
+
for split_name in splits_names
|
122 |
+
for fold_id in fold_ids
|
123 |
+
]
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
def _generate_examples(self, filepath, split_id):
|
126 |
with open(filepath, "r", encoding="latin-1") as f:
|