Upload DataSet.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103from datasets import load_datasetimport json
_DESCRIPTION = "This is a testing dataset"
_CITATION = """\@inproceedings{clark2019boolq, title={DataSet: Understand the working of Huggig Face}, author={DataMetica}}"""
_URLS = { "train": "train/" + "*.jsonl", "test": "test/" + "*.json",}
def _info(self): return datasets.DatasetInfo( description = _description, features = datasets.Features( { "HIVE": datasets.Value("string"), "BQ": datasets.Value("string"), } ), )
load_dataset("dataSet")
class DataSetConfig(datasets.BuilderConfig): """BuilderConfig for SuperGLUE."""
def __init__(self, features, citation, url, label_classes=("False", "True"), **kwargs): """BuilderConfig for DataSet. Args: features: `list[string]`, list of the features that will appear in the feature dict. Should not include "label". data_url: `string`, url to download the zip file from. citation: `string`, citation for the data set. url: `string`, url for information about the data set. label_classes: `list[string]`, the list of classes for the label if the label is present as a string. Non-string labels will be cast to either 'False' or 'True'. **kwargs: keyword arguments forwarded to super. """ # Version history: # 1.0.0: Initial version. super(DataSetConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs) self.features = features self.label_classes = label_classes self.citation = citation self.url = url
class DataSet(datasets.GeneratorBasedBuilder): """The SuperGLUE benchmark."""
BUILDER_CONFIGS = [ DataSetConfig( name="dataSet", description=_DESCRIPTION, features=["HIVE", "BQ"], supervised_keys=None, citation=_BOOLQ_CITATION, url="" )
def _info(self): features = {feature: datasets.Value("string") for feature in self.config.features} return datasets.DatasetInfo( description=_GLUE_DESCRIPTION + self.config.description, features=datasets.Features(features), homepage=self.config.url, citation=self.config.citation + "\n" + _SUPER_GLUE_CITATION, )
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]: urls_to_download = self._URLS downloaded_files = dl_manager.download_and_extract(urls_to_download)
return [ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}), datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}), ]
def _generate_examples(self, filepath): """This function returns the examples in the raw (text) form.""" logger.info("generating examples from = %s", filepath) with open(filepath) as f: squad = json.load(f) for element in squad["data"]: inputQuery = article.get("HIVE", "").strip() output = article.get("BQ", "").strip() # Features currently used are "context", "question", and "answers". # Others are extracted here for the ease of future expansions. yield id_, { "HIVE": {inputQuery}, "BQ": {output} }
DataSet.pyAdded+103