|
|
|
""" |
|
""" |
|
try: |
|
import ir_datasets |
|
except ImportError as e: |
|
raise ImportError('ir-datasets package missing; `pip install ir-datasets`') |
|
import datasets |
|
|
|
IRDS_ID = 'msmarco-passage/trec-dl-hard/fold3' |
|
IRDS_ENTITY_TYPES = {'queries': {'query_id': 'string', 'text': 'string'}, 'qrels': {'query_id': 'string', 'doc_id': 'string', 'relevance': 'int64'}} |
|
|
|
_CITATION = '@article{Mackie2021DlHard,\n title={How Deep is your Learning: the DL-HARD Annotated Deep Learning Dataset},\n author={Iain Mackie and Jeffrey Dalton and Andrew Yates},\n journal={ArXiv},\n year={2021},\n volume={abs/2105.07975}\n}\n@inproceedings{Bajaj2016Msmarco,\n title={MS MARCO: A Human Generated MAchine Reading COmprehension Dataset},\n author={Payal Bajaj, Daniel Campos, Nick Craswell, Li Deng, Jianfeng Gao, Xiaodong Liu, Rangan Majumder, Andrew McNamara, Bhaskar Mitra, Tri Nguyen, Mir Rosenberg, Xia Song, Alina Stoica, Saurabh Tiwary, Tong Wang},\n booktitle={InCoCo@NIPS},\n year={2016}\n}' |
|
|
|
_DESCRIPTION = "" |
|
|
|
class msmarco_passage_trec_dl_hard_fold3(datasets.GeneratorBasedBuilder): |
|
BUILDER_CONFIGS = [datasets.BuilderConfig(name=e) for e in IRDS_ENTITY_TYPES] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features({k: datasets.Value(v) for k, v in IRDS_ENTITY_TYPES[self.config.name].items()}), |
|
homepage=f"https://ir-datasets.com/msmarco-passage#msmarco-passage/trec-dl-hard/fold3", |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
return [datasets.SplitGenerator(name=self.config.name)] |
|
|
|
def _generate_examples(self): |
|
dataset = ir_datasets.load(IRDS_ID) |
|
for i, item in enumerate(getattr(dataset, self.config.name)): |
|
key = i |
|
if self.config.name == 'docs': |
|
key = item.doc_id |
|
elif self.config.name == 'queries': |
|
key = item.query_id |
|
yield key, item._asdict() |
|
|
|
def as_dataset(self, split=None, *args, **kwargs): |
|
split = self.config.name |
|
return super().as_dataset(split, *args, **kwargs) |
|
|