| import json |
| import datasets |
|
|
| class ClipCc(datasets.GeneratorBasedBuilder): |
| VERSION = datasets.Version("1.0.0") |
|
|
| def _info(self): |
| return datasets.DatasetInfo( |
| description="A dataset of 200 video summaries with corresponding YouTube links and IDs.", |
| features=datasets.Features( |
| { |
| "id": datasets.Value("string"), |
| "file_link": datasets.Value("string"), |
| "summary": datasets.Value("string"), |
| } |
| ), |
| supervised_keys=None, |
| homepage="https://huggingface.co/datasets/IVSL-SDSU/Clip-CC", |
| license="apache-2.0" |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| data_path = dl_manager.download_and_extract("metadata.jsonl") |
| return [ |
| datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_path}) |
| ] |
|
|
| def _generate_examples(self, filepath): |
| with open(filepath, encoding="utf-8") as f: |
| for idx, line in enumerate(f): |
| item = json.loads(line) |
| yield idx, { |
| "id": item.get("id", ""), |
| "file_link": item.get("file_link", ""), |
| "summary": item.get("summary", ""), |
| } |
|
|