Datasets:
License:
Upload aftdb.py
Browse files
aftdb.py
CHANGED
|
@@ -43,14 +43,13 @@ class AFTConfig(datasets.BuilderConfig):
|
|
| 43 |
"""Builder Config for AFTdb"""
|
| 44 |
|
| 45 |
def __init__(self, nb_files_figure, nb_files_table, **kwargs):
|
| 46 |
-
"""BuilderConfig for AFTdb."""
|
| 47 |
super().__init__(version=datasets.__version__, **kwargs)
|
| 48 |
self.nb_files_figure = nb_files_figure
|
| 49 |
self.nb_files_table = nb_files_table
|
| 50 |
|
| 51 |
|
| 52 |
class AFT_Dataset(datasets.GeneratorBasedBuilder):
|
| 53 |
-
"""Arxiv Figure Table (
|
| 54 |
|
| 55 |
BUILDER_CONFIGS = [
|
| 56 |
AFTConfig(
|
|
@@ -59,7 +58,7 @@ class AFT_Dataset(datasets.GeneratorBasedBuilder):
|
|
| 59 |
"Dataset containing scientific article figures associated "
|
| 60 |
"with their caption, summary, and article title."
|
| 61 |
),
|
| 62 |
-
data_dir="./{type}",
|
| 63 |
nb_files_figure=_NB_TAR_FIGURE,
|
| 64 |
nb_files_table=None
|
| 65 |
),
|
|
@@ -71,7 +70,7 @@ class AFT_Dataset(datasets.GeneratorBasedBuilder):
|
|
| 71 |
"representation of the table, including its caption, summary, "
|
| 72 |
"and article title."
|
| 73 |
),
|
| 74 |
-
data_dir="./{type}",
|
| 75 |
nb_files_figure=None,
|
| 76 |
nb_files_table=_NB_TAR_TABLE
|
| 77 |
),
|
|
@@ -83,7 +82,7 @@ class AFT_Dataset(datasets.GeneratorBasedBuilder):
|
|
| 83 |
"textual representation of the table, including its caption, "
|
| 84 |
"summary, and article title."
|
| 85 |
),
|
| 86 |
-
data_dir="./{type}",
|
| 87 |
nb_files_figure=_NB_TAR_FIGURE,
|
| 88 |
nb_files_table=_NB_TAR_TABLE
|
| 89 |
)
|
|
@@ -136,32 +135,57 @@ class AFT_Dataset(datasets.GeneratorBasedBuilder):
|
|
| 136 |
data_dir=self.config.data_dir.format(type='table'),
|
| 137 |
nb_files=self.config.nb_files_table
|
| 138 |
)
|
|
|
|
| 139 |
if dl_manager.is_streaming:
|
| 140 |
downloaded_files = dl_manager.download(all_path)
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
else:
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
)
|
| 164 |
-
|
| 165 |
|
| 166 |
def _generate_examples(self, filepaths, is_streaming):
|
| 167 |
if is_streaming:
|
|
|
|
| 43 |
"""Builder Config for AFTdb"""
|
| 44 |
|
| 45 |
def __init__(self, nb_files_figure, nb_files_table, **kwargs):
|
|
|
|
| 46 |
super().__init__(version=datasets.__version__, **kwargs)
|
| 47 |
self.nb_files_figure = nb_files_figure
|
| 48 |
self.nb_files_table = nb_files_table
|
| 49 |
|
| 50 |
|
| 51 |
class AFT_Dataset(datasets.GeneratorBasedBuilder):
|
| 52 |
+
"""Arxiv Figure Table database (AFTdb)"""
|
| 53 |
|
| 54 |
BUILDER_CONFIGS = [
|
| 55 |
AFTConfig(
|
|
|
|
| 58 |
"Dataset containing scientific article figures associated "
|
| 59 |
"with their caption, summary, and article title."
|
| 60 |
),
|
| 61 |
+
data_dir="./data/arxiv_dataset/{type}", # A modiféer sur Huggingface Hub
|
| 62 |
nb_files_figure=_NB_TAR_FIGURE,
|
| 63 |
nb_files_table=None
|
| 64 |
),
|
|
|
|
| 70 |
"representation of the table, including its caption, summary, "
|
| 71 |
"and article title."
|
| 72 |
),
|
| 73 |
+
data_dir="./data/arxiv_dataset/{type}", # A modiféer sur Huggingface Hub
|
| 74 |
nb_files_figure=None,
|
| 75 |
nb_files_table=_NB_TAR_TABLE
|
| 76 |
),
|
|
|
|
| 82 |
"textual representation of the table, including its caption, "
|
| 83 |
"summary, and article title."
|
| 84 |
),
|
| 85 |
+
data_dir="./data/arxiv_dataset/{type}", # A modiféer sur Huggingface Hub
|
| 86 |
nb_files_figure=_NB_TAR_FIGURE,
|
| 87 |
nb_files_table=_NB_TAR_TABLE
|
| 88 |
)
|
|
|
|
| 135 |
data_dir=self.config.data_dir.format(type='table'),
|
| 136 |
nb_files=self.config.nb_files_table
|
| 137 |
)
|
| 138 |
+
dataset = []
|
| 139 |
if dl_manager.is_streaming:
|
| 140 |
downloaded_files = dl_manager.download(all_path)
|
| 141 |
+
dataset.append(
|
| 142 |
+
datasets.SplitGenerator(
|
| 143 |
+
name=datasets.Split.TRAIN,
|
| 144 |
+
gen_kwargs={
|
| 145 |
+
'filepaths': [
|
| 146 |
+
dl_manager.iter_archive(ii)
|
| 147 |
+
for ii in downloaded_files['train']
|
| 148 |
+
],
|
| 149 |
+
'is_streaming': dl_manager.is_streaming
|
| 150 |
+
}
|
| 151 |
+
)
|
| 152 |
+
)
|
| 153 |
+
dataset.append(
|
| 154 |
+
datasets.SplitGenerator(
|
| 155 |
+
name=datasets.Split.TEST,
|
| 156 |
+
gen_kwargs={
|
| 157 |
+
"filepaths": [
|
| 158 |
+
dl_manager.iter_archive(ii)
|
| 159 |
+
for ii in downloaded_files['test']
|
| 160 |
+
],
|
| 161 |
+
'is_streaming': dl_manager.is_streaming
|
| 162 |
+
}
|
| 163 |
+
)
|
| 164 |
+
)
|
| 165 |
else:
|
| 166 |
+
dataset.append(
|
| 167 |
+
datasets.SplitGenerator(
|
| 168 |
+
name=datasets.Split.TRAIN,
|
| 169 |
+
gen_kwargs={
|
| 170 |
+
'filepaths': dl_manager.download_and_extract(
|
| 171 |
+
all_path['train']
|
| 172 |
+
),
|
| 173 |
+
'is_streaming': dl_manager.is_streaming
|
| 174 |
+
}
|
| 175 |
+
)
|
| 176 |
+
)
|
| 177 |
+
dataset.append(
|
| 178 |
+
datasets.SplitGenerator(
|
| 179 |
+
name=datasets.Split.TEST,
|
| 180 |
+
gen_kwargs={
|
| 181 |
+
"filepaths": dl_manager.download_and_extract(
|
| 182 |
+
all_path['test']
|
| 183 |
+
),
|
| 184 |
+
'is_streaming': dl_manager.is_streaming
|
| 185 |
+
}
|
| 186 |
+
)
|
| 187 |
)
|
| 188 |
+
return dataset
|
| 189 |
|
| 190 |
def _generate_examples(self, filepaths, is_streaming):
|
| 191 |
if is_streaming:
|