""" """ # TODO try: import ir_datasets except ImportError as e: raise ImportError('ir-datasets package missing; `pip install ir-datasets`') import datasets IRDS_ID = 'car/v1.5/trec-y1/auto' IRDS_ENTITY_TYPES = {'qrels': {'query_id': 'string', 'doc_id': 'string', 'relevance': 'int64', 'iteration': 'string'}} _CITATION = '@inproceedings{Dietz2017TrecCar,\n title={TREC Complex Answer Retrieval Overview.},\n author={Dietz, Laura and Verma, Manisha and Radlinski, Filip and Craswell, Nick},\n booktitle={TREC},\n year={2017}\n}\n@article{Dietz2017Car,\n title={{TREC CAR}: A Data Set for Complex Answer Retrieval},\n author={Laura Dietz and Ben Gamari},\n year={2017},\n note={Version 1.5},\n url={http://trec-car.cs.unh.edu}\n}' _DESCRIPTION = "" # TODO class car_v1.5_trec_y1_auto(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/car#car/v1.5/trec-y1/auto", 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 # always return split corresponding with this config to avid returning a redundant DatasetDict layer return super().as_dataset(split, *args, **kwargs)