(path: str, name: List[str] = None, samples: int = None)
| 14 | |
| 15 | @staticmethod |
| 16 | def load(path: str, name: List[str] = None, samples: int = None): |
| 17 | path = get_data_path(path, local_mode=True) |
| 18 | |
| 19 | # Check if file exists in the given path |
| 20 | supported_extensions = ['jsonl'] |
| 21 | for ext in supported_extensions: |
| 22 | filename = osp.join( |
| 23 | path, f'{name}.{ext}') # name refers to data subset name |
| 24 | |
| 25 | if osp.exists(filename): |
| 26 | break |
| 27 | else: |
| 28 | raise FileNotFoundError(f'{filename} not found.') |
| 29 | |
| 30 | samples = 'test' if samples is None else f'test[:{samples}]' |
| 31 | |
| 32 | data_files = {'test': filename} |
| 33 | |
| 34 | dataset = load_dataset('json', data_files=data_files, split=samples) |
| 35 | |
| 36 | # Filter out empty samples |
| 37 | dataset = dataset.filter(lambda example: len(example['text']) > 0) |
| 38 | |
| 39 | return dataset |
nothing calls this directly
no test coverage detected