diff --git a/datasets/swda/swda.py b/datasets/swda/swda.py index 4ad179b55e3..7323f871832 100644 --- a/datasets/swda/swda.py +++ b/datasets/swda/swda.py @@ -26,7 +26,6 @@ import csv import datetime import glob -import io import os import re @@ -435,10 +434,8 @@ def _split_generators(self, dl_manager): dl_dir = dl_manager.download_and_extract(_URL) # Use swda/ folder. data_dir = os.path.join(dl_dir, "swda") - # Handle partitions files. - urls_to_download = self._URLS - # Download extract and return paths of split files. - downloaded_files = dl_manager.download_and_extract(urls_to_download) + # Handle partitions files: download extract and return paths of split files. + downloaded_files = dl_manager.download(self._URLS) return [ # Return whole data path and train splits file downloaded path. @@ -476,7 +473,8 @@ def _generate_examples(self, data_dir, split_file): """ # Read in the split file. - split_file = io.open(file=split_file, mode="r", encoding="utf-8").read().splitlines() + with open(file=split_file, mode="r", encoding="utf-8") as f: + split_file = f.read().splitlines() # Read in corpus data using split files. corpus = CorpusReader(src_dirname=data_dir, split_file=split_file) # Generate examples.