Commit
·
fff9c79
1
Parent(s):
c310749
Support streaming xtreme dataset for bucc18 config (#4026)
Browse filesCommit from https://github.com/huggingface/datasets/commit/369dadbd775a9db07a2db9a571d1a69cdf20b13c
xtreme.py
CHANGED
@@ -659,22 +659,20 @@ class Xtreme(datasets.GeneratorBasedBuilder):
|
|
659 |
]
|
660 |
if self.config.name.startswith("bucc18"):
|
661 |
lang = self.config.name.split(".")[1]
|
662 |
-
|
663 |
self.config.data_url + f"bucc2018-{lang}-en.training-gold.tar.bz2"
|
664 |
)
|
665 |
-
|
666 |
self.config.data_url + f"bucc2018-{lang}-en.sample-gold.tar.bz2"
|
667 |
)
|
668 |
return [
|
669 |
datasets.SplitGenerator(
|
670 |
name=datasets.Split.VALIDATION,
|
671 |
-
|
672 |
-
gen_kwargs={"filepath": os.path.join(bucc18_dl_dev_dir, "bucc2018", lang + "-en")},
|
673 |
),
|
674 |
datasets.SplitGenerator(
|
675 |
name=datasets.Split.TEST,
|
676 |
-
|
677 |
-
gen_kwargs={"filepath": os.path.join(bucc18_dl_test_dir, "bucc2018", lang + "-en")},
|
678 |
),
|
679 |
]
|
680 |
if self.config.name.startswith("udpos"):
|
@@ -886,26 +884,17 @@ class Xtreme(datasets.GeneratorBasedBuilder):
|
|
886 |
},
|
887 |
}
|
888 |
if self.config.name.startswith("bucc18"):
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
with open(target_file, encoding="utf-8") as f:
|
901 |
-
data = csv.reader(f, delimiter="\t")
|
902 |
-
target_sentences = [row for row in data]
|
903 |
-
with open(source_file, encoding="utf-8") as f:
|
904 |
-
data = csv.reader(f, delimiter="\t")
|
905 |
-
source_sentences = [row for row in data]
|
906 |
-
with open(source_target_file, encoding="utf-8") as f:
|
907 |
-
data = csv.reader(f, delimiter="\t")
|
908 |
-
source_target_ids = [row for row in data]
|
909 |
for id_, pair in enumerate(source_target_ids):
|
910 |
source_id = pair[0]
|
911 |
target_id = pair[1]
|
|
|
659 |
]
|
660 |
if self.config.name.startswith("bucc18"):
|
661 |
lang = self.config.name.split(".")[1]
|
662 |
+
bucc18_dl_test_archive = dl_manager.download(
|
663 |
self.config.data_url + f"bucc2018-{lang}-en.training-gold.tar.bz2"
|
664 |
)
|
665 |
+
bucc18_dl_dev_archive = dl_manager.download(
|
666 |
self.config.data_url + f"bucc2018-{lang}-en.sample-gold.tar.bz2"
|
667 |
)
|
668 |
return [
|
669 |
datasets.SplitGenerator(
|
670 |
name=datasets.Split.VALIDATION,
|
671 |
+
gen_kwargs={"filepath": dl_manager.iter_archive(bucc18_dl_dev_archive)},
|
|
|
672 |
),
|
673 |
datasets.SplitGenerator(
|
674 |
name=datasets.Split.TEST,
|
675 |
+
gen_kwargs={"filepath": dl_manager.iter_archive(bucc18_dl_test_archive)},
|
|
|
676 |
),
|
677 |
]
|
678 |
if self.config.name.startswith("udpos"):
|
|
|
884 |
},
|
885 |
}
|
886 |
if self.config.name.startswith("bucc18"):
|
887 |
+
lang = self.config.name.split(".")[1]
|
888 |
+
data_dir = f"bucc2018/{lang}-en"
|
889 |
+
for path, file in filepath:
|
890 |
+
if path.startswith(data_dir):
|
891 |
+
csv_content = [line.decode("utf-8") for line in file]
|
892 |
+
if path.endswith("en"):
|
893 |
+
target_sentences = list(csv.reader(csv_content, delimiter="\t"))
|
894 |
+
elif path.endswith("gold"):
|
895 |
+
source_target_ids = list(csv.reader(csv_content, delimiter="\t"))
|
896 |
+
else:
|
897 |
+
source_sentences = list(csv.reader(csv_content, delimiter="\t"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
898 |
for id_, pair in enumerate(source_target_ids):
|
899 |
source_id = pair[0]
|
900 |
target_id = pair[1]
|