Upload DataSet.py
Browse files- DataSet.py +1 -102
DataSet.py
CHANGED
|
@@ -1,103 +1,2 @@
|
|
| 1 |
from datasets import load_dataset
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
_DESCRIPTION = "This is a testing dataset"
|
| 5 |
-
|
| 6 |
-
_CITATION = """\
|
| 7 |
-
@inproceedings{clark2019boolq,
|
| 8 |
-
title={DataSet: Understand the working of Huggig Face},
|
| 9 |
-
author={DataMetica}
|
| 10 |
-
}"""
|
| 11 |
-
|
| 12 |
-
_URLS = {
|
| 13 |
-
"train": "train/" + "*.jsonl",
|
| 14 |
-
"test": "test/" + "*.json",
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
def _info(self):
|
| 18 |
-
return datasets.DatasetInfo(
|
| 19 |
-
description = _description,
|
| 20 |
-
features = datasets.Features(
|
| 21 |
-
{
|
| 22 |
-
"HIVE": datasets.Value("string"),
|
| 23 |
-
"BQ": datasets.Value("string"),
|
| 24 |
-
}
|
| 25 |
-
),
|
| 26 |
-
)
|
| 27 |
-
|
| 28 |
-
load_dataset("dataSet")
|
| 29 |
-
|
| 30 |
-
class DataSetConfig(datasets.BuilderConfig):
|
| 31 |
-
"""BuilderConfig for SuperGLUE."""
|
| 32 |
-
|
| 33 |
-
def __init__(self, features, citation, url, label_classes=("False", "True"), **kwargs):
|
| 34 |
-
"""BuilderConfig for DataSet.
|
| 35 |
-
Args:
|
| 36 |
-
features: `list[string]`, list of the features that will appear in the
|
| 37 |
-
feature dict. Should not include "label".
|
| 38 |
-
data_url: `string`, url to download the zip file from.
|
| 39 |
-
citation: `string`, citation for the data set.
|
| 40 |
-
url: `string`, url for information about the data set.
|
| 41 |
-
label_classes: `list[string]`, the list of classes for the label if the
|
| 42 |
-
label is present as a string. Non-string labels will be cast to either
|
| 43 |
-
'False' or 'True'.
|
| 44 |
-
**kwargs: keyword arguments forwarded to super.
|
| 45 |
-
"""
|
| 46 |
-
# Version history:
|
| 47 |
-
# 1.0.0: Initial version.
|
| 48 |
-
super(DataSetConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs)
|
| 49 |
-
self.features = features
|
| 50 |
-
self.label_classes = label_classes
|
| 51 |
-
self.citation = citation
|
| 52 |
-
self.url = url
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
class DataSet(datasets.GeneratorBasedBuilder):
|
| 56 |
-
"""The SuperGLUE benchmark."""
|
| 57 |
-
|
| 58 |
-
BUILDER_CONFIGS = [
|
| 59 |
-
DataSetConfig(
|
| 60 |
-
name="dataSet",
|
| 61 |
-
description=_DESCRIPTION,
|
| 62 |
-
features=["HIVE", "BQ"],
|
| 63 |
-
supervised_keys=None,
|
| 64 |
-
citation=_BOOLQ_CITATION,
|
| 65 |
-
url=""
|
| 66 |
-
)
|
| 67 |
-
|
| 68 |
-
def _info(self):
|
| 69 |
-
features = {feature: datasets.Value("string") for feature in self.config.features}
|
| 70 |
-
return datasets.DatasetInfo(
|
| 71 |
-
description=_GLUE_DESCRIPTION + self.config.description,
|
| 72 |
-
features=datasets.Features(features),
|
| 73 |
-
homepage=self.config.url,
|
| 74 |
-
citation=self.config.citation + "\n" + _SUPER_GLUE_CITATION,
|
| 75 |
-
)
|
| 76 |
-
|
| 77 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
| 78 |
-
urls_to_download = self._URLS
|
| 79 |
-
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
| 80 |
-
|
| 81 |
-
return [
|
| 82 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
| 83 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
| 84 |
-
]
|
| 85 |
-
|
| 86 |
-
def _generate_examples(self, filepath):
|
| 87 |
-
"""This function returns the examples in the raw (text) form."""
|
| 88 |
-
logger.info("generating examples from = %s", filepath)
|
| 89 |
-
with open(filepath) as f:
|
| 90 |
-
squad = json.load(f)
|
| 91 |
-
for element in squad["data"]:
|
| 92 |
-
inputQuery = article.get("HIVE", "").strip()
|
| 93 |
-
output = article.get("BQ", "").strip()
|
| 94 |
-
# Features currently used are "context", "question", and "answers".
|
| 95 |
-
# Others are extracted here for the ease of future expansions.
|
| 96 |
-
yield id_, {
|
| 97 |
-
"HIVE": {inputQuery},
|
| 98 |
-
"BQ": {output}
|
| 99 |
-
}
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
| 1 |
from datasets import load_dataset
|
| 2 |
+
load_dataset("sg19296/DataSet")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|