Commit
•
39d6ce3
1
Parent(s):
cc5866e
Optimize code to perform less requests
Browse files- ask_a_patient.py +13 -20
ask_a_patient.py
CHANGED
@@ -13,9 +13,7 @@
|
|
13 |
# See the License for the specific language governing permissions and
|
14 |
# limitations under the License.
|
15 |
|
16 |
-
import glob
|
17 |
import os
|
18 |
-
import re
|
19 |
|
20 |
import datasets
|
21 |
|
@@ -109,24 +107,19 @@ class AskAPatient(datasets.GeneratorBasedBuilder):
|
|
109 |
dl_dir = dl_manager.download_and_extract(_URLs)
|
110 |
dataset_dir = os.path.join(dl_dir, "datasets", "AskAPatient")
|
111 |
# dataset supports k-folds
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
datasets.
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
name=split_id,
|
126 |
-
gen_kwargs={"filepath": fold_filepath, "split_id": split_id},
|
127 |
-
)
|
128 |
-
)
|
129 |
-
return splits
|
130 |
|
131 |
def _generate_examples(self, filepath, split_id):
|
132 |
with open(filepath, "r", encoding="latin-1") as f:
|
|
|
13 |
# See the License for the specific language governing permissions and
|
14 |
# limitations under the License.
|
15 |
|
|
|
16 |
import os
|
|
|
17 |
|
18 |
import datasets
|
19 |
|
|
|
107 |
dl_dir = dl_manager.download_and_extract(_URLs)
|
108 |
dataset_dir = os.path.join(dl_dir, "datasets", "AskAPatient")
|
109 |
# dataset supports k-folds
|
110 |
+
splits_names = ["train", "validation", "test"]
|
111 |
+
fold_ids = range(10)
|
112 |
+
return [
|
113 |
+
datasets.SplitGenerator(
|
114 |
+
name=f"{split_name}_{fold_id}",
|
115 |
+
gen_kwargs={
|
116 |
+
"filepath": os.path.join(dataset_dir, f"AskAPatient.fold-{fold_id}.{split_name}.txt"),
|
117 |
+
"split_id": f"{split_name}_{fold_id}",
|
118 |
+
},
|
119 |
+
)
|
120 |
+
for split_name in splits_names
|
121 |
+
for fold_id in fold_ids
|
122 |
+
]
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
def _generate_examples(self, filepath, split_id):
|
125 |
with open(filepath, "r", encoding="latin-1") as f:
|