File size: 2,267 Bytes
48c90a6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
"""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 |