|
33 | 33 |
|
34 | 34 | @_add_docstring_header(num_lines=NUM_LINES, num_classes=5) |
35 | 35 | @_create_dataset_directory(dataset_name=DATASET_NAME) |
36 | | -@_wrap_split_argument(('train', 'test')) |
| 36 | +@_wrap_split_argument(("train", "test")) |
37 | 37 | def YelpReviewFull(root: str, split: Union[Tuple[str], str]): |
38 | 38 | if not is_module_available("torchdata"): |
39 | 39 | raise ModuleNotFoundError("Package `torchdata` not found. Please install following instructions at `https://github.com/pytorch/data`") |
40 | 40 |
|
41 | 41 | url_dp = IterableWrapper([URL]) |
42 | 42 |
|
43 | | - cache_dp = url_dp.on_disk_cache( |
| 43 | + cache_compressed_dp = url_dp.on_disk_cache( |
44 | 44 | filepath_fn=lambda x: os.path.join(root, _PATH), |
45 | 45 | hash_dict={os.path.join(root, _PATH): MD5}, hash_type="md5" |
46 | 46 | ) |
47 | | - cache_dp = GDriveReader(cache_dp).end_caching(mode="wb", same_filepath_fn=True) |
48 | | - cache_dp = FileOpener(cache_dp, mode="b") |
| 47 | + cache_compressed_dp = GDriveReader(cache_compressed_dp) |
| 48 | + cache_compressed_dp = cache_compressed_dp.end_caching(mode="wb", same_filepath_fn=True) |
49 | 49 |
|
50 | | - extracted_files = cache_dp.read_from_tar() |
| 50 | + cache_decompressed_dp = cache_compressed_dp.on_disk_cache(filepath_fn=lambda x: os.path.join(root, _EXTRACTED_FILES[split])) |
| 51 | + cache_decompressed_dp = FileOpener(cache_decompressed_dp, mode="b") |
| 52 | + cache_decompressed_dp = cache_decompressed_dp.read_from_tar().filter(lambda x: _EXTRACTED_FILES[split] in x[0]) |
| 53 | + cache_decompressed_dp = cache_decompressed_dp.end_caching(mode="wb", same_filepath_fn=True) |
51 | 54 |
|
52 | | - filter_extracted_files = extracted_files.filter(lambda x: _EXTRACTED_FILES[split] in x[0]) |
53 | | - |
54 | | - return filter_extracted_files.parse_csv().map(fn=lambda t: (int(t[0]), " ".join(t[1:]))) |
| 55 | + data_dp = FileOpener(cache_decompressed_dp, mode="b") |
| 56 | + return data_dp.parse_csv().map(fn=lambda t: (int(t[0]), " ".join(t[1:]))) |
0 commit comments