Update dataset.py
Browse files5 unmodified lines6789101112131415161718192021222324252627282930313233343517 unmodified lines5354553233343536373839404156575859606162456364656649676869705371727374577576775 unmodified linesclass M3Retrieve(datasets.GeneratorBasedBuilder): VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [ datasets.BuilderConfig(name=subfolder, version=VERSION, description=f"Dataset for {subfolder}") for subfolder in [ "Anatomy_and_Physiology", "Cardiology", "Dermatology", "Endocrinology_and_Diabetes", "Gastroenterology", "Hematology", "Microbiology_and_Cell_Biology", "Miscellaneous", "Neurology_and_Neuroscience", "Ophthalmology_and_Sensory_Systems", "Orthopedics_and_Musculoskeletal", "Pharmacology", "Psychiatry_and_Mental_Health", "Pubmed", "Radiology_and_Imaging", "Reproductive_System", "Respiratory_and_Pulmonology", "Surgical_Specialties", ] ]
def _info(self): return datasets.DatasetInfo( description="M3Retrieve: Benchmarking Multimodal Retrieval for Medicine",17 unmodified lines )
def _split_generators(self, dl_manager): """Returns SplitGenerators for a specific subfolder.""" data_dir = dl_manager.download_and_extract(self.config.data_dir) # Extract the folder name from self.config.name subfolder = os.path.join(data_dir, self.config.name) # Validate that the subfolder exists if not os.path.isdir(subfolder): raise ValueError(f"Dataset folder '{self.config.name}' not found in {data_dir}.") """Returns SplitGenerators.""" dataset_name = self.config.name # Get the selected dataset folder name data_dir = os.path.join(self.config.data_dir, dataset_name) # Set path to selected dataset return [ datasets.SplitGenerator( name="queries", gen_kwargs={"filepath": os.path.join(subfolder, "queries.jsonl"), "key": "queries"}, gen_kwargs={"filepath": os.path.join(data_dir, "queries.jsonl"), "key": "queries"}, ), datasets.SplitGenerator( name="corpus", gen_kwargs={"filepath": os.path.join(subfolder, "corpus.jsonl"), "key": "corpus"}, gen_kwargs={"filepath": os.path.join(data_dir, "corpus.jsonl"), "key": "corpus"}, ), datasets.SplitGenerator( name="qrels", gen_kwargs={"filepath": os.path.join(subfolder, "qrels/test.tsv"), "key": "qrels"}, gen_kwargs={"filepath": os.path.join(data_dir, "qrels/test.tsv"), "key": "qrels"}, ), ]
def _generate_examples(self, filepath, key): """Yields examples as (key, example) tuples.""" if key in ["queries", "corpus"]:dataset.py+31-14