r"""A dataset loader using a global config. It will load the train, valid, and test set (if exists) simulatenously.
(dataset)
| 9 | from openprompt.data_utils.data_processor import DataProcessor |
| 10 | |
| 11 | def load_dataset(dataset): |
| 12 | r"""A dataset loader using a global config. |
| 13 | It will load the train, valid, and test set (if exists) simulatenously. |
| 14 | |
| 15 | """ |
| 16 | |
| 17 | processor = PROCESSORS[dataset.lower()]() |
| 18 | path = 'datasets/' + dataset.lower().split('-')[0] |
| 19 | |
| 20 | train_dataset = None |
| 21 | valid_dataset = None |
| 22 | |
| 23 | try: |
| 24 | train_dataset = processor.get_train_examples(path) |
| 25 | except FileNotFoundError: |
| 26 | logger.warning(f"Has no training dataset in {path}.") |
| 27 | try: |
| 28 | valid_dataset = processor.get_dev_examples(path) |
| 29 | except FileNotFoundError: |
| 30 | logger.warning(f"Has no validation dataset in {path}.") |
| 31 | |
| 32 | test_dataset = None |
| 33 | try: |
| 34 | test_dataset = processor.get_test_examples(path) |
| 35 | except FileNotFoundError: |
| 36 | logger.warning(f"Has no test dataset in {path}.") |
| 37 | # checking whether donwloaded. |
| 38 | if (train_dataset is None) and \ |
| 39 | (valid_dataset is None) and \ |
| 40 | (test_dataset is None): |
| 41 | logger.error("Dataset is empty. Either there is no download or the path is wrong. "+ \ |
| 42 | "If not downloaded, please `cd datasets/` and `bash download_xxx.sh`") |
| 43 | exit() |
| 44 | return train_dataset, valid_dataset, test_dataset, processor |
| 45 | |
| 46 | |
| 47 | class MnlimmProcessor(DataProcessor): |