may-ohta commited on
Commit
705443a
1 Parent(s): 309d724

Update damt.py

Browse files
Files changed (1) hide show
  1. damt.py +22 -7
damt.py CHANGED
@@ -1,7 +1,11 @@
1
  # coding=utf-8
2
  """Multi-domain German-English parallel dataset for Domain Adapted Machine Translation."""
3
 
 
 
4
  import datasets
 
 
5
 
6
  _CITATION = """\
7
  @inproceedings{koehn-knowles-2017-six,
@@ -86,19 +90,30 @@ class DAMT(datasets.GeneratorBasedBuilder):
86
  def _get_drive_url(url):
87
  return f"https://drive.google.com/uc?id={url.split('/')[5]}"
88
 
89
- dl_dir = dl_manager.download_and_extract(_get_drive_url(_URL))
 
 
 
 
 
 
 
 
 
 
 
90
  files = {
91
  "train": {
92
- "en_file": f"{dl_dir}/{domain}/train.en",
93
- "de_file": f"{dl_dir}/{domain}/train.de",
94
  },
95
  "validation": {
96
- "en_file": f"{dl_dir}/{domain}/dev.en",
97
- "de_file": f"{dl_dir}/{domain}/dev.de",
98
  },
99
  "test": {
100
- "en_file": f"{dl_dir}/{domain}/test.en",
101
- "de_file": f"{dl_dir}/{domain}/test.de",
102
  },
103
  }
104
 
 
1
  # coding=utf-8
2
  """Multi-domain German-English parallel dataset for Domain Adapted Machine Translation."""
3
 
4
+ from pathlib import Path
5
+
6
  import datasets
7
+ import gdown
8
+
9
 
10
  _CITATION = """\
11
  @inproceedings{koehn-knowles-2017-six,
 
90
  def _get_drive_url(url):
91
  return f"https://drive.google.com/uc?id={url.split('/')[5]}"
92
 
93
+ cache_dir = dl_manager.download_config.cache_dir
94
+ assert Path(cache_dir).is_dir()
95
+
96
+ output = Path(cache_dir) / "multi_domain_new_split.zip"
97
+ if not output.exists():
98
+ dl_dir = gdown.download(_get_drive_url(_URL), output.as_posix(), quiet=True)
99
+ else:
100
+ dl_dir = output.as_posix()
101
+
102
+ ex_dir = dl_manager.extract(dl_dir)
103
+ assert Path(ex_dir).is_dir(), ex_dir
104
+
105
  files = {
106
  "train": {
107
+ "en_file": f"{ex_dir}/{domain}/train.en",
108
+ "de_file": f"{ex_dir}/{domain}/train.de",
109
  },
110
  "validation": {
111
+ "en_file": f"{ex_dir}/{domain}/dev.en",
112
+ "de_file": f"{ex_dir}/{domain}/dev.de",
113
  },
114
  "test": {
115
+ "en_file": f"{ex_dir}/{domain}/test.en",
116
+ "de_file": f"{ex_dir}/{domain}/test.de",
117
  },
118
  }
119