Upload date-data.py with huggingface_hub
Browse files- date-data.py +3 -21
date-data.py
CHANGED
|
@@ -10,10 +10,8 @@ fs = HfFileSystem()
|
|
| 10 |
_CITATION = """
|
| 11 |
"""
|
| 12 |
|
| 13 |
-
_DESCRIPTION = """
|
| 14 |
-
|
| 15 |
-
It's created with purpose is practice loading dataset from hugging face hub.
|
| 16 |
-
"""
|
| 17 |
|
| 18 |
|
| 19 |
_HOMEPAGE = """
|
|
@@ -32,7 +30,6 @@ _CONFIGS.extend(
|
|
| 32 |
for file in fs.listdir(_REPO_BRANCH + "/data/", detail=False)
|
| 33 |
if file.endswith('.zip')
|
| 34 |
)
|
| 35 |
-
print("_CONFIGS", _CONFIGS[:3])
|
| 36 |
|
| 37 |
class DateDataConfig(datasets.BuilderConfig):
|
| 38 |
def __init__(
|
|
@@ -45,7 +42,6 @@ class DateDataConfig(datasets.BuilderConfig):
|
|
| 45 |
version=datasets.Version("1.0.0"),
|
| 46 |
description=_DESCRIPTION,
|
| 47 |
)
|
| 48 |
-
print('construct DateDataConfig', name)
|
| 49 |
|
| 50 |
class DateDate(datasets.GeneratorBasedBuilder):
|
| 51 |
BUILDER_CONFIGS = [DateDataConfig(name=name) for name in _CONFIGS]
|
|
@@ -64,7 +60,6 @@ class DateDate(datasets.GeneratorBasedBuilder):
|
|
| 64 |
"year": datasets.Value('string'),
|
| 65 |
"file_path": datasets.Value('string'),
|
| 66 |
})
|
| 67 |
-
print('Features ', self.BUILDER_CONFIGS[2:5])
|
| 68 |
return datasets.DatasetInfo(
|
| 69 |
features=features,
|
| 70 |
description=_DESCRIPTION,
|
|
@@ -82,14 +77,7 @@ class DateDate(datasets.GeneratorBasedBuilder):
|
|
| 82 |
data_dirs = dl_manager.download_and_extract(
|
| 83 |
[_URL.format(filename=zipfile) for zipfile in config_names]
|
| 84 |
)
|
| 85 |
-
|
| 86 |
-
datasets.SplitGenerator(
|
| 87 |
-
name=datasets.Split.TRAIN,
|
| 88 |
-
gen_kwargs={
|
| 89 |
-
"data_dirs": data_dirs,
|
| 90 |
-
}
|
| 91 |
-
)
|
| 92 |
-
])
|
| 93 |
return [
|
| 94 |
datasets.SplitGenerator(
|
| 95 |
name=datasets.Split.TRAIN,
|
|
@@ -99,27 +87,21 @@ class DateDate(datasets.GeneratorBasedBuilder):
|
|
| 99 |
)
|
| 100 |
]
|
| 101 |
|
| 102 |
-
|
| 103 |
def _generate_examples(
|
| 104 |
self,
|
| 105 |
data_dirs: List[str],
|
| 106 |
) -> dict:
|
| 107 |
-
print("_generate_examples", data_dirs)
|
| 108 |
for i, data_dir in enumerate(data_dirs):
|
| 109 |
sample = self._extract_datetime("Wed Oct 16 11:08:00 +07 2024")
|
| 110 |
sample.update((('id','123'),('file_path',"null")))
|
| 111 |
-
print(sample)
|
| 112 |
yield i, sample
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
def _read_txt(
|
| 117 |
self,
|
| 118 |
file_name: str,
|
| 119 |
) -> str:
|
| 120 |
with open(file=file_name, mode='r') as f:
|
| 121 |
return self._extract_datetime(f.read())
|
| 122 |
-
|
| 123 |
|
| 124 |
def _extract_datetime(
|
| 125 |
self,
|
|
|
|
| 10 |
_CITATION = """
|
| 11 |
"""
|
| 12 |
|
| 13 |
+
_DESCRIPTION = """This dataset contain file about datetime date.
|
| 14 |
+
It's created with purpose is practice loading dataset from hugging face hub."""
|
|
|
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
_HOMEPAGE = """
|
|
|
|
| 30 |
for file in fs.listdir(_REPO_BRANCH + "/data/", detail=False)
|
| 31 |
if file.endswith('.zip')
|
| 32 |
)
|
|
|
|
| 33 |
|
| 34 |
class DateDataConfig(datasets.BuilderConfig):
|
| 35 |
def __init__(
|
|
|
|
| 42 |
version=datasets.Version("1.0.0"),
|
| 43 |
description=_DESCRIPTION,
|
| 44 |
)
|
|
|
|
| 45 |
|
| 46 |
class DateDate(datasets.GeneratorBasedBuilder):
|
| 47 |
BUILDER_CONFIGS = [DateDataConfig(name=name) for name in _CONFIGS]
|
|
|
|
| 60 |
"year": datasets.Value('string'),
|
| 61 |
"file_path": datasets.Value('string'),
|
| 62 |
})
|
|
|
|
| 63 |
return datasets.DatasetInfo(
|
| 64 |
features=features,
|
| 65 |
description=_DESCRIPTION,
|
|
|
|
| 77 |
data_dirs = dl_manager.download_and_extract(
|
| 78 |
[_URL.format(filename=zipfile) for zipfile in config_names]
|
| 79 |
)
|
| 80 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
return [
|
| 82 |
datasets.SplitGenerator(
|
| 83 |
name=datasets.Split.TRAIN,
|
|
|
|
| 87 |
)
|
| 88 |
]
|
| 89 |
|
|
|
|
| 90 |
def _generate_examples(
|
| 91 |
self,
|
| 92 |
data_dirs: List[str],
|
| 93 |
) -> dict:
|
|
|
|
| 94 |
for i, data_dir in enumerate(data_dirs):
|
| 95 |
sample = self._extract_datetime("Wed Oct 16 11:08:00 +07 2024")
|
| 96 |
sample.update((('id','123'),('file_path',"null")))
|
|
|
|
| 97 |
yield i, sample
|
| 98 |
|
|
|
|
|
|
|
| 99 |
def _read_txt(
|
| 100 |
self,
|
| 101 |
file_name: str,
|
| 102 |
) -> str:
|
| 103 |
with open(file=file_name, mode='r') as f:
|
| 104 |
return self._extract_datetime(f.read())
|
|
|
|
| 105 |
|
| 106 |
def _extract_datetime(
|
| 107 |
self,
|