| import datasets |
| import os |
| import json |
|
|
|
|
| _CITATION = """ |
| |
| """ |
|
|
| _DESCRIPTION = """ |
| |
| """ |
|
|
| class Builder(datasets.GeneratorBasedBuilder): |
| VERSION = datasets.Version("1.0.0") |
|
|
| BUILDER_CONFIGS = [ |
| datasets.BuilderConfig(name=name, version=datasets.Version("1.0.0"), description=_DESCRIPTION) |
| for name in ["regular", "trec"] |
| ] |
|
|
| def _info(self): |
| features = datasets.Features( |
| { |
| "text": datasets.Value("string"), |
| "references": datasets.Sequence({ |
| "id": datasets.Value("string"), |
| "text": datasets.Value("string"), |
| "is_gold": datasets.Value("bool"), |
| "relevance": datasets.Value("int64"), |
| "rank": datasets.Value("int64"), |
|
|
| }), |
| "golds": datasets.Sequence({ |
| "id": datasets.Value("string"), |
| "text": datasets.Value("string"), |
| "is_gold": datasets.Value("bool"), |
| "relevance": datasets.Value("int64"), |
| "rank": datasets.Value("int64"), |
| }), |
| } |
| ) |
| return datasets.DatasetInfo( |
| description=_DESCRIPTION, |
| features=features, |
| homepage="", |
| license="", |
| citation=_CITATION, |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| train_json = dl_manager.download(os.path.join(self.config.name, "train.jsonl")) |
| valid_json = dl_manager.download(os.path.join(self.config.name, "valid.jsonl")) |
|
|
| return [ |
| datasets.SplitGenerator( |
| name=datasets.Split.TRAIN, |
| gen_kwargs={"path": train_json}, |
| ), |
| datasets.SplitGenerator( |
| name=datasets.Split.VALIDATION, |
| gen_kwargs={"path": valid_json}, |
| ), |
| ] |
|
|
| |
| def _generate_examples(self, path): |
| with open(path, encoding="utf-8") as f: |
| for key, row in enumerate(f): |
| yield key, json.loads(row) |
|
|