import json import datasets class SkillDataset(datasets.GeneratorBasedBuilder): VERSION = datasets.Version("0.1.0") def _info(self): return datasets.DatasetInfo( description="A dataset of skills and their descriptions", features=datasets.Features( { "summary": datasets.Value("string"), "dialogue": datasets.Value("string"), } ), ) def _split_generators(self, dl_manager): mappings = json.load(open("mappings.json", "r")) training_data = mappings[:int(0.95 * len(mappings))] testing_data = mappings[int(0.95 * len(mappings)) :] return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={ "data": training_data, "split": "train" } ), datasets.SplitGenerator( name=datasets.Split.TEST, gen_kwargs={ "data": testing_data, "split": "test", } ), datasets.SplitGenerator( name=datasets.Split.VALIDATION, gen_kwargs={ "data": testing_data, "split": "val", } ), ] def _generate_examples(self, data): for i, mapping in enumerate(data): yield i, { "summary": mapping["summary"], "dialogue": mapping["dialogue"], }