Upload 2 files
Browse files- aptani2_config.tar.gz +3 -0
- aptani2param.py +54 -0
aptani2_config.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a4eb134894fe9a3335803a35e724ebb17208901594c45add9dc8e9d67314f8b0
|
| 3 |
+
size 1684044
|
aptani2param.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import datasets
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
logger = datasets.logging.get_logger(__name__)
|
| 6 |
+
|
| 7 |
+
ID_POOL = ("default", "origin")
|
| 8 |
+
URL = "https://huggingface.co/datasets/thewall/thewall/Aptani2Param/resolve/main"
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class Aptani2ParamConfig(datasets.BuilderConfig):
|
| 12 |
+
pass
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class Aptani2Param(datasets.GeneratorBasedBuilder):
|
| 16 |
+
BUILDER_CONFIGS = [
|
| 17 |
+
Aptani2ParamConfig(name=key) for key in ID_POOL
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
DEFAULT_CONFIG_NAME = "default"
|
| 21 |
+
|
| 22 |
+
def _info(self):
|
| 23 |
+
return datasets.DatasetInfo(
|
| 24 |
+
features=datasets.Features(
|
| 25 |
+
{
|
| 26 |
+
"config": datasets.Value("string"),
|
| 27 |
+
"existed": datasets.Value("bool"),
|
| 28 |
+
}
|
| 29 |
+
),
|
| 30 |
+
homepage="http://aptani.unimore.it/",
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
def _split_generators(self, dl_manager):
|
| 34 |
+
aptani2_url = f"{URL}/aptani2_config.tar.gz"
|
| 35 |
+
downloaded_files = [os.path.join(f"{dl_manager.download_and_extract(aptani2_url)}", self.config.name)]
|
| 36 |
+
return [
|
| 37 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files}),
|
| 38 |
+
]
|
| 39 |
+
|
| 40 |
+
def _generate_examples(self, filepath):
|
| 41 |
+
"""This function returns the examples in the raw (text) form."""
|
| 42 |
+
logger.info("generating examples from = %s", filepath)
|
| 43 |
+
flag = True
|
| 44 |
+
for file in filepath:
|
| 45 |
+
flag = flag and os.path.exists(file)
|
| 46 |
+
|
| 47 |
+
yield 0, {"config": filepath[0],
|
| 48 |
+
"existed": flag
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
if __name__=="__main__":
|
| 53 |
+
from datasets import load_dataset
|
| 54 |
+
dataset = load_dataset("aptani2param.py", split="all")
|