|
import csv |
|
import datasets |
|
|
|
class Finstsb(datasets.GeneratorBasedBuilder): |
|
"""Finstsb dataset.""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description="Finstsb dataset", |
|
features=datasets.Features( |
|
{ |
|
"sentence1": datasets.Value("string"), |
|
"sentence2": datasets.Value("string"), |
|
"gpt_score": datasets.Value("int32"), |
|
"score": datasets.Value("int32"), |
|
} |
|
), |
|
supervised_keys=None, |
|
homepage="https://huggingface.co/datasets", |
|
citation="", |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
urls_to_download = { |
|
"dev": "path/to/your/finstsb_to_dev.csv", |
|
"test": "path/to/your/finstsb_to_test.csv", |
|
} |
|
downloaded_files = dl_manager.download_and_extract(urls_to_download) |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
gen_kwargs={"filepath": downloaded_files["dev"]}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
gen_kwargs={"filepath": downloaded_files["test"]}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, filepath): |
|
"""Yields examples.""" |
|
with open(filepath, encoding="utf-8") as f: |
|
reader = csv.DictReader(f) |
|
for id_, row in enumerate(reader): |
|
yield id_, { |
|
"sentence1": row["sentence1"], |
|
"sentence2": row["sentence2"], |
|
"gpt_score": int(row["gpt_score"]), |
|
"score": int(row["score"]), |
|
} |
|
|