|
"""ReLi dataset""" |
|
|
|
import datasets |
|
import pandas as pd |
|
|
|
_CITATION = """ |
|
""" |
|
|
|
_DESCRIPTION = """ |
|
""" |
|
|
|
_URLS = { |
|
"train": "https://raw.githubusercontent.com/ruanchaves/reli/048eb86f046cedb32acf8d982be004c7c749b3b8/train.csv", |
|
"test": "https://raw.githubusercontent.com/ruanchaves/reli/048eb86f046cedb32acf8d982be004c7c749b3b8/test.csv", |
|
"validation": "https://raw.githubusercontent.com/ruanchaves/reli/048eb86f046cedb32acf8d982be004c7c749b3b8/dev.csv" |
|
} |
|
|
|
class Reli(datasets.GeneratorBasedBuilder): |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"source": datasets.Value("string"), |
|
"title": datasets.Value("string"), |
|
"book": datasets.Value("string"), |
|
"review_id": datasets.Value("string"), |
|
"score": datasets.Value("float64"), |
|
"sentence_id": datasets.Value("int64"), |
|
"unique_review_id": datasets.Value("string"), |
|
"sentence": datasets.Value("string"), |
|
"label": datasets.Value("string") |
|
}), |
|
supervised_keys=None, |
|
homepage="", |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
downloaded_files = dl_manager.download(_URLS) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"filepath": downloaded_files["train"], |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
gen_kwargs={ |
|
"filepath": downloaded_files["validation"], |
|
} |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
gen_kwargs={ |
|
"filepath": downloaded_files["test"], |
|
} |
|
) |
|
] |
|
|
|
def _generate_examples(self, filepath): |
|
records = pd.read_csv(filepath).to_dict("records") |
|
for idx, row in enumerate(records): |
|
yield idx, row |