|
"""A dataset script that will hit Snowflake DB and return the results.""" |
|
|
|
import snowflake.connector as connector |
|
|
|
import datasets |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
@InProceedings{huggingface:dataset, |
|
title = {A great new dataset}, |
|
author={huggingface, Inc. |
|
}, |
|
year={2020} |
|
} |
|
""" |
|
|
|
|
|
|
|
_DESCRIPTION = """\ |
|
This new dataset is designed to solve this great NLP task and is crafted with a lot of care. |
|
""" |
|
|
|
|
|
_HOMEPAGE = "" |
|
|
|
|
|
_LICENSE = "" |
|
|
|
|
|
|
|
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], |
|
} |
|
|
|
cursor.connection.close() |
|
|