Update files from the datasets library (from 1.16.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.16.0
- hansards.py +3 -5
hansards.py
CHANGED
@@ -114,16 +114,14 @@ class Hansards(datasets.GeneratorBasedBuilder):
|
|
114 |
"test": _DATA_URL + _SENATE_DEBATES_TEST_SET_FILE,
|
115 |
}
|
116 |
else:
|
117 |
-
raise ValueError("Wrong builder config name '{}', it has to be either 'house' or 'senate'."
|
118 |
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
119 |
if type(downloaded_files) == str:
|
120 |
downloaded_files = {k: downloaded_files for k in urls_to_download.keys()}
|
121 |
fr_files = {}
|
122 |
en_files = {}
|
123 |
for split_name in downloaded_files.keys():
|
124 |
-
archive_dir = "hansard.36/Release-2001.1a/sentence-pairs/{}/debates/development/{}"
|
125 |
-
name, split_name + "ing"
|
126 |
-
)
|
127 |
data_dir = os.path.join(downloaded_files[split_name], archive_dir)
|
128 |
split_compress_files = list(sorted(glob.glob(os.path.join(data_dir, "*.gz"))))
|
129 |
split_compress_files += list(sorted(glob.glob(os.path.join(data_dir, "**/*.gz"))))
|
@@ -151,6 +149,6 @@ class Hansards(datasets.GeneratorBasedBuilder):
|
|
151 |
with open(fr_file, "rb") as fr:
|
152 |
with open(en_file, "rb") as en:
|
153 |
for j, (fr_line, en_line) in enumerate(zip(fr, en)):
|
154 |
-
line_id = "{}:{}"
|
155 |
rec = {"fr": fr_line.decode("ISO-8859-1").strip(), "en": en_line.decode("ISO-8859-1").strip()}
|
156 |
yield line_id, rec
|
114 |
"test": _DATA_URL + _SENATE_DEBATES_TEST_SET_FILE,
|
115 |
}
|
116 |
else:
|
117 |
+
raise ValueError(f"Wrong builder config name '{name}', it has to be either 'house' or 'senate'.")
|
118 |
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
119 |
if type(downloaded_files) == str:
|
120 |
downloaded_files = {k: downloaded_files for k in urls_to_download.keys()}
|
121 |
fr_files = {}
|
122 |
en_files = {}
|
123 |
for split_name in downloaded_files.keys():
|
124 |
+
archive_dir = f"hansard.36/Release-2001.1a/sentence-pairs/{name}/debates/development/{split_name + 'ing'}"
|
|
|
|
|
125 |
data_dir = os.path.join(downloaded_files[split_name], archive_dir)
|
126 |
split_compress_files = list(sorted(glob.glob(os.path.join(data_dir, "*.gz"))))
|
127 |
split_compress_files += list(sorted(glob.glob(os.path.join(data_dir, "**/*.gz"))))
|
149 |
with open(fr_file, "rb") as fr:
|
150 |
with open(en_file, "rb") as en:
|
151 |
for j, (fr_line, en_line) in enumerate(zip(fr, en)):
|
152 |
+
line_id = f"{fr_file}:{j}"
|
153 |
rec = {"fr": fr_line.decode("ISO-8859-1").strip(), "en": en_line.decode("ISO-8859-1").strip()}
|
154 |
yield line_id, rec
|