Datasets:

Update tatoeba_mt.py

#2
by Muennighoff - opened
Files changed (1) hide show
  1. tatoeba_mt.py +30 -24
tatoeba_mt.py CHANGED
@@ -109,31 +109,37 @@ class tatoebaMT(datasets.GeneratorBasedBuilder):
109
 
110
  lang_pair = self.config.language_pair
111
  # release = self.config.release
112
-
113
- files = {
114
- "test": os.path.join("test", f"tatoeba-test.{lang_pair}.tsv"),
115
- "validation": os.path.join("dev", f"tatoeba-dev.{lang_pair}.tsv")
116
- }
117
- data_dir = dl_manager.download_and_extract(files)
118
-
 
 
 
 
 
 
119
  output = []
120
- # if os.path.exists(data_dir["test"]):
121
- test = datasets.SplitGenerator(
122
- name=datasets.Split.TEST,
123
- gen_kwargs={
124
- "filepath": data_dir["test"]
125
- }
126
- )
127
- output.append(test)
128
-
129
- #if os.path.exists(data_dir["validation"]):
130
- valid = datasets.SplitGenerator(
131
- name=datasets.Split.VALIDATION,
132
- gen_kwargs={
133
- "filepath": data_dir["validation"]
134
- }
135
- )
136
- output.append(valid)
137
 
138
  return output
139
 
 
109
 
110
  lang_pair = self.config.language_pair
111
  # release = self.config.release
112
+
113
+ files = {}
114
+
115
+ test_path = os.path.join("test", f"tatoeba-test.{lang_pair}.tsv")
116
+ files["test"] = test_path
117
+ valid_path = os.path.join("test", f"tatoeba-dev.{lang_pair}.tsv")
118
+ files["validation"] = valid_path
119
+ try:
120
+ data_dir = dl_manager.download_and_extract(files)
121
+ except:
122
+ files.pop("validation")
123
+ data_dir = dl_manager.download_and_extract(files)
124
+
125
  output = []
126
+ if "test" in files:
127
+ test = datasets.SplitGenerator(
128
+ name=datasets.Split.TEST,
129
+ gen_kwargs={
130
+ "filepath": data_dir["test"]
131
+ }
132
+ )
133
+ output.append(test)
134
+
135
+ if "validation" in files:
136
+ valid = datasets.SplitGenerator(
137
+ name=datasets.Split.VALIDATION,
138
+ gen_kwargs={
139
+ "filepath": data_dir["validation"]
140
+ }
141
+ )
142
+ output.append(valid)
143
 
144
  return output
145