"""A dataset script that will hit Snowflake DB and return the results.""" import snowflake.connector as connector import datasets # TODO: Add BibTeX citation # Find for instance the citation on arxiv or on the dataset repo/website _CITATION = """\ @InProceedings{huggingface:dataset, title = {A great new dataset}, author={huggingface, Inc. }, year={2020} } """ # TODO: Add description of the dataset here # You can copy an official description _DESCRIPTION = """\ This new dataset is designed to solve this great NLP task and is crafted with a lot of care. """ # TODO: Add a link to an official homepage for the dataset here _HOMEPAGE = "" # TODO: Add the licence for the dataset here if you can find it _LICENSE = "" # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case class NewDataset(datasets.GeneratorBasedBuilder): """TODO: Short description of my dataset.""" def _info(self): return datasets.DatasetInfo( description=_DESCRIPTION, features=datasets.Features( { "text": datasets.Value("string"), "label": datasets.ClassLabel(names=['sadness', 'joy', 'love', 'anger', 'fear', 'surprise']), } ), homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION, ) def _split_generators(self, dl_manager): conn = connector.connect( user='rajiv', password='Password123!', account='VUA92284', warehouse='RAJIV', database='HUGGINGFACE', schema='PUBLIC', role = 'RAJIV' ) curr = conn.cursor() sql = "select * from EMOTION" curr = curr.execute(sql) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={"cursor": curr}, ) ] def _generate_examples(self, cursor): for i, ex in enumerate(cursor): yield str(i), { "text": ex[0], "label": ex[1], } # Probably not necessary but just in case...we close the connection which we can find within the cursor object cursor.connection.close()