| """Yandex.Q questions and answers dataset""" |
|
|
|
|
| import json |
|
|
| import datasets |
|
|
| _DESCRIPTION = """\ |
| This is a dataset of questions and answers scraped from Yandex.Q. |
| """ |
|
|
| _HOMEPAGE = "https://huggingface.co/datasets/its5Q/yandex-q" |
|
|
| _LICENSE = "cc0-1.0" |
|
|
| _URLS = [ |
| "https://huggingface.co/datasets/its5Q/yandex-q/resolve/main/answers.jsonl.gz" |
| ] |
|
|
|
|
| class YandexQ(datasets.GeneratorBasedBuilder): |
| VERSION = datasets.Version("0.1.0") |
|
|
| def _info(self): |
| return datasets.DatasetInfo( |
| description=_DESCRIPTION, |
| features=datasets.Features( |
| { |
| "description": datasets.Value("string"), |
| "question": datasets.Value("string"), |
| "answer": datasets.Value("string") |
| } |
| ), |
| homepage=_HOMEPAGE, |
| license=_LICENSE |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| data_dir = dl_manager.download_and_extract(_URLS) |
| return [ |
| datasets.SplitGenerator( |
| name=datasets.Split.TRAIN, |
| gen_kwargs={ |
| "filepath": data_dir[0], |
| "split": "train", |
| }, |
| ) |
| ] |
|
|
| def _generate_examples(self, filepath, split): |
| with open(filepath, 'r', encoding="utf-8") as f: |
| for i, line in enumerate(f): |
| data = json.loads(line) |
| if data['description'] is None: |
| data['description'] = '' |
| yield i, data |
|
|
|
|