may-ohta commited on
Commit
a0a0f4a
1 Parent(s): 32dc538

Update iwslt14.py

Browse files
Files changed (1) hide show
  1. iwslt14.py +13 -12
iwslt14.py CHANGED
@@ -175,15 +175,16 @@ class IWSLT14(datasets.GeneratorBasedBuilder):
175
  talk_id = f"d{doc_counter}"
176
  flag = ""
177
  for source_file, target_file in zip(source_files, target_files):
178
- src = _parse(source_file)
179
- trg = _parse(target_file)
180
-
181
- for k, src_sent in src.items():
182
- if k in trg:
183
- trg_sent = trg[k]
184
-
185
- yield id_, {
186
- "id": k,
187
- "translation": {source: src_sent, target: trg_sent}
188
- }
189
- id_ += 1
 
 
175
  talk_id = f"d{doc_counter}"
176
  flag = ""
177
  for source_file, target_file in zip(source_files, target_files):
178
+ if Path(source_file).is_file() and Path(target_file).is_file():
179
+ src = _parse(source_file)
180
+ trg = _parse(target_file)
181
+
182
+ for k, src_sent in src.items():
183
+ if k in trg:
184
+ trg_sent = trg[k]
185
+
186
+ yield id_, {
187
+ "id": k,
188
+ "translation": {source: src_sent, target: trg_sent}
189
+ }
190
+ id_ += 1