We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
text/test/translation.py fails for custom paths
`text/test/translation.py` currently fails on the last section:

```python
train, val = datasets.TranslationDataset.splits(
    path='.data/multi30k/', train='train',
    validation='val', exts=('.de', '.en'),
    fields=(DE, EN))
```

because `splits` expects TranslationDataset.name to be defined, but it isn't.
Possible fix: add `name = ''` to `TranslationDataset`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `torchtext/datasets/translation.py`
Content:
```
1 import os
2 import xml.etree.ElementTree as ET
3 import glob
4 import io
5 
6 from .. import data
7 
8 
9 class TranslationDataset(data.Dataset):
10     """Defines a dataset for machine translation."""
11 
12     @staticmethod
13     def sort_key(ex):
14         return data.interleave_keys(len(ex.src), len(ex.trg))
15 
16     def __init__(self, path, exts, fields, **kwargs):
17         """Create a TranslationDataset given paths and fields.
18 
19         Arguments:
20             path: Common prefix of paths to the data files for both languages.
21             exts: A tuple containing the extension to path for each language.
22             fields: A tuple containing the fields that will be used for data
23                 in each language.
24             Remaining keyword arguments: Passed to the constructor of
25                 data.Dataset.
26         """
27         if not isinstance(fields[0], (tuple, list)):
28             fields = [('src', fields[0]), ('trg', fields[1])]
29 
30         src_path, trg_path = tuple(os.path.expanduser(path + x) for x in exts)
31 
32         examples = []
33         with open(src_path) as src_file, open(trg_path) as trg_file:
34             for src_line, trg_line in zip(src_file, trg_file):
35                 src_line, trg_line = src_line.strip(), trg_line.strip()
36                 if src_line != '' and trg_line != '':
37                     examples.append(data.Example.fromlist(
38                         [src_line, trg_line], fields))
39 
40         super(TranslationDataset, self).__init__(examples, fields, **kwargs)
41 
42     @classmethod
43     def splits(cls, exts, fields, root='.data',
44                train='train', validation='val', test='test', **kwargs):
45         """Create dataset objects for splits of a TranslationDataset.
46 
47         Arguments:
48 
49             root: Root dataset storage directory. Default is '.data'.
50             exts: A tuple containing the extension to path for each language.
51             fields: A tuple containing the fields that will be used for data
52                 in each language.
53             train: The prefix of the train data. Default: 'train'.
54             validation: The prefix of the validation data. Default: 'val'.
55             test: The prefix of the test data. Default: 'test'.
56             Remaining keyword arguments: Passed to the splits method of
57                 Dataset.
58         """
59         path = cls.download(root)
60 
61         train_data = None if train is None else cls(
62             os.path.join(path, train), exts, fields, **kwargs)
63         val_data = None if validation is None else cls(
64             os.path.join(path, validation), exts, fields, **kwargs)
65         test_data = None if test is None else cls(
66             os.path.join(path, test), exts, fields, **kwargs)
67         return tuple(d for d in (train_data, val_data, test_data)
68                      if d is not None)
69 
70 
71 class Multi30k(TranslationDataset):
72     """The small-dataset WMT 2016 multimodal task, also known as Flickr30k"""
73 
74     urls = ['http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/training.tar.gz',
75             'http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/validation.tar.gz',
76             'http://www.quest.dcs.shef.ac.uk/'
77             'wmt17_files_mmt/mmt_task1_test2016.tar.gz']
78     name = 'multi30k'
79     dirname = ''
80 
81     @classmethod
82     def splits(cls, exts, fields, root='.data',
83                train='train', validation='val', test='test2016', **kwargs):
84         """Create dataset objects for splits of the Multi30k dataset.
85 
86         Arguments:
87 
88             root: Root dataset storage directory. Default is '.data'.
89             exts: A tuple containing the extension to path for each language.
90             fields: A tuple containing the fields that will be used for data
91                 in each language.
92             train: The prefix of the train data. Default: 'train'.
93             validation: The prefix of the validation data. Default: 'val'.
94             test: The prefix of the test data. Default: 'test'.
95             Remaining keyword arguments: Passed to the splits method of
96                 Dataset.
97         """
98         return super(Multi30k, cls).splits(
99             exts, fields, root, train, validation, test, **kwargs)
100 
101 
102 class IWSLT(TranslationDataset):
103     """The IWSLT 2016 TED talk translation task"""
104 
105     base_url = 'https://wit3.fbk.eu/archive/2016-01//texts/{}/{}/{}.tgz'
106     name = 'iwslt'
107     base_dirname = '{}-{}'
108 
109     @classmethod
110     def splits(cls, exts, fields, root='.data',
111                train='train', validation='IWSLT16.TED.tst2013',
112                test='IWSLT16.TED.tst2014', **kwargs):
113         """Create dataset objects for splits of the IWSLT dataset.
114 
115         Arguments:
116 
117             root: Root dataset storage directory. Default is '.data'.
118             exts: A tuple containing the extension to path for each language.
119             fields: A tuple containing the fields that will be used for data
120                 in each language.
121             train: The prefix of the train data. Default: 'train'.
122             validation: The prefix of the validation data. Default: 'val'.
123             test: The prefix of the test data. Default: 'test'.
124             Remaining keyword arguments: Passed to the splits method of
125                 Dataset.
126         """
127         cls.dirname = cls.base_dirname.format(exts[0][1:], exts[1][1:])
128         cls.urls = [cls.base_url.format(exts[0][1:], exts[1][1:], cls.dirname)]
129         check = os.path.join(root, cls.name, cls.dirname)
130         path = cls.download(root, check=check)
131 
132         train = '.'.join([train, cls.dirname])
133         validation = '.'.join([validation, cls.dirname])
134         if test is not None:
135             test = '.'.join([test, cls.dirname])
136 
137         if not os.path.exists(os.path.join(path, train) + exts[0]):
138             cls.clean(path)
139 
140         train_data = None if train is None else cls(
141             os.path.join(path, train), exts, fields, **kwargs)
142         val_data = None if validation is None else cls(
143             os.path.join(path, validation), exts, fields, **kwargs)
144         test_data = None if test is None else cls(
145             os.path.join(path, test), exts, fields, **kwargs)
146         return tuple(d for d in (train_data, val_data, test_data)
147                      if d is not None)
148 
149     @staticmethod
150     def clean(path):
151         for f_xml in glob.iglob(os.path.join(path, '*.xml')):
152             print(f_xml)
153             f_txt = os.path.splitext(f_xml)[0]
154             with io.open(f_txt, mode='w', encoding='utf-8') as fd_txt:
155                 root = ET.parse(f_xml).getroot()[0]
156                 for doc in root.findall('doc'):
157                     for e in doc.findall('seg'):
158                         fd_txt.write(e.text.strip() + '\n')
159 
160         xml_tags = ['<url', '<keywords', '<talkid', '<description',
161                     '<reviewer', '<translator', '<title', '<speaker']
162         for f_orig in glob.iglob(os.path.join(path, 'train.tags*')):
163             print(f_orig)
164             f_txt = f_orig.replace('.tags', '')
165             with io.open(f_txt, mode='w', encoding='utf-8') as fd_txt, \
166                     io.open(f_orig, mode='r', encoding='utf-8') as fd_orig:
167                 for l in fd_orig:
168                     if not any(tag in l for tag in xml_tags):
169                         fd_txt.write(l.strip() + '\n')
170 
171 
172 class WMT14(TranslationDataset):
173     """The WMT 2014 English-German dataset, as preprocessed by Google Brain.
174 
175     Though this download contains test sets from 2015 and 2016, the train set
176     differs slightly from WMT 2015 and 2016 and significantly from WMT 2017."""
177 
178     urls = [('https://drive.google.com/uc?export=download&'
179              'id=0B_bZck-ksdkpM25jRUN2X2UxMm8', 'wmt16_en_de.tar.gz')]
180     name = 'wmt14'
181     dirname = ''
182 
183     @classmethod
184     def splits(cls, exts, fields, root='.data',
185                train='train.tok.clean.bpe.32000',
186                validation='newstest2013.tok.bpe.32000',
187                test='newstest2014.tok.bpe.32000', **kwargs):
188         """Create dataset objects for splits of the WMT 2014 dataset.
189 
190         Arguments:
191 
192             root: Root dataset storage directory. Default is '.data'.
193             exts: A tuple containing the extensions for each language. Must be
194                 either ('.en', '.de') or the reverse.
195             fields: A tuple containing the fields that will be used for data
196                 in each language.
197             train: The prefix of the train data. Default:
198                 'train.tok.clean.bpe.32000'.
199             validation: The prefix of the validation data. Default:
200                 'newstest2013.tok.bpe.32000'.
201             test: The prefix of the test data. Default:
202                 'newstest2014.tok.bpe.32000'.
203             Remaining keyword arguments: Passed to the splits method of
204                 Dataset.
205         """
206         return super(WMT14, cls).splits(
207             exts, fields, root, train, validation, test, **kwargs)
208
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/torchtext/datasets/translation.py b/torchtext/datasets/translation.py
--- a/torchtext/datasets/translation.py
+++ b/torchtext/datasets/translation.py
@@ -40,12 +40,13 @@
         super(TranslationDataset, self).__init__(examples, fields, **kwargs)
 
     @classmethod
-    def splits(cls, exts, fields, root='.data',
+    def splits(cls, exts, fields, path=None, root='.data',
                train='train', validation='val', test='test', **kwargs):
         """Create dataset objects for splits of a TranslationDataset.
 
         Arguments:
-
+            path (str): Common prefix of the splits' file paths, or None to use
+                the result of cls.download(root).
             root: Root dataset storage directory. Default is '.data'.
             exts: A tuple containing the extension to path for each language.
             fields: A tuple containing the fields that will be used for data
@@ -56,7 +57,8 @@
             Remaining keyword arguments: Passed to the splits method of
                 Dataset.
         """
-        path = cls.download(root)
+        if path is None:
+            path = cls.download(root)
 
         train_data = None if train is None else cls(
             os.path.join(path, train), exts, fields, **kwargs)

{"golden_diff": "diff --git a/torchtext/datasets/translation.py b/torchtext/datasets/translation.py\n--- a/torchtext/datasets/translation.py\n+++ b/torchtext/datasets/translation.py\n@@ -40,12 +40,13 @@\n         super(TranslationDataset, self).__init__(examples, fields, **kwargs)\n \n     @classmethod\n-    def splits(cls, exts, fields, root='.data',\n+    def splits(cls, exts, fields, path=None, root='.data',\n                train='train', validation='val', test='test', **kwargs):\n         \"\"\"Create dataset objects for splits of a TranslationDataset.\n \n         Arguments:\n-\n+            path (str): Common prefix of the splits' file paths, or None to use\n+                the result of cls.download(root).\n             root: Root dataset storage directory. Default is '.data'.\n             exts: A tuple containing the extension to path for each language.\n             fields: A tuple containing the fields that will be used for data\n@@ -56,7 +57,8 @@\n             Remaining keyword arguments: Passed to the splits method of\n                 Dataset.\n         \"\"\"\n-        path = cls.download(root)\n+        if path is None:\n+            path = cls.download(root)\n \n         train_data = None if train is None else cls(\n             os.path.join(path, train), exts, fields, **kwargs)\n", "issue": "text/test/translation.py fails for custom paths\n`text/test/translation.py` currently fails on the last section:\r\n\r\n```python\r\ntrain, val = datasets.TranslationDataset.splits(\r\n    path='.data/multi30k/', train='train',\r\n    validation='val', exts=('.de', '.en'),\r\n    fields=(DE, EN))\r\n```\r\n\r\nbecause `splits` expects TranslationDataset.name to be defined, but it isn't.\r\nPossible fix: add `name = ''` to `TranslationDataset`\n", "before_files": [{"content": "import os\nimport xml.etree.ElementTree as ET\nimport glob\nimport io\n\nfrom .. import data\n\n\nclass TranslationDataset(data.Dataset):\n    \"\"\"Defines a dataset for machine translation.\"\"\"\n\n    @staticmethod\n    def sort_key(ex):\n        return data.interleave_keys(len(ex.src), len(ex.trg))\n\n    def __init__(self, path, exts, fields, **kwargs):\n        \"\"\"Create a TranslationDataset given paths and fields.\n\n        Arguments:\n            path: Common prefix of paths to the data files for both languages.\n            exts: A tuple containing the extension to path for each language.\n            fields: A tuple containing the fields that will be used for data\n                in each language.\n            Remaining keyword arguments: Passed to the constructor of\n                data.Dataset.\n        \"\"\"\n        if not isinstance(fields[0], (tuple, list)):\n            fields = [('src', fields[0]), ('trg', fields[1])]\n\n        src_path, trg_path = tuple(os.path.expanduser(path + x) for x in exts)\n\n        examples = []\n        with open(src_path) as src_file, open(trg_path) as trg_file:\n            for src_line, trg_line in zip(src_file, trg_file):\n                src_line, trg_line = src_line.strip(), trg_line.strip()\n                if src_line != '' and trg_line != '':\n                    examples.append(data.Example.fromlist(\n                        [src_line, trg_line], fields))\n\n        super(TranslationDataset, self).__init__(examples, fields, **kwargs)\n\n    @classmethod\n    def splits(cls, exts, fields, root='.data',\n               train='train', validation='val', test='test', **kwargs):\n        \"\"\"Create dataset objects for splits of a TranslationDataset.\n\n        Arguments:\n\n            root: Root dataset storage directory. Default is '.data'.\n            exts: A tuple containing the extension to path for each language.\n            fields: A tuple containing the fields that will be used for data\n                in each language.\n            train: The prefix of the train data. Default: 'train'.\n            validation: The prefix of the validation data. Default: 'val'.\n            test: The prefix of the test data. Default: 'test'.\n            Remaining keyword arguments: Passed to the splits method of\n                Dataset.\n        \"\"\"\n        path = cls.download(root)\n\n        train_data = None if train is None else cls(\n            os.path.join(path, train), exts, fields, **kwargs)\n        val_data = None if validation is None else cls(\n            os.path.join(path, validation), exts, fields, **kwargs)\n        test_data = None if test is None else cls(\n            os.path.join(path, test), exts, fields, **kwargs)\n        return tuple(d for d in (train_data, val_data, test_data)\n                     if d is not None)\n\n\nclass Multi30k(TranslationDataset):\n    \"\"\"The small-dataset WMT 2016 multimodal task, also known as Flickr30k\"\"\"\n\n    urls = ['http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/training.tar.gz',\n            'http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/validation.tar.gz',\n            'http://www.quest.dcs.shef.ac.uk/'\n            'wmt17_files_mmt/mmt_task1_test2016.tar.gz']\n    name = 'multi30k'\n    dirname = ''\n\n    @classmethod\n    def splits(cls, exts, fields, root='.data',\n               train='train', validation='val', test='test2016', **kwargs):\n        \"\"\"Create dataset objects for splits of the Multi30k dataset.\n\n        Arguments:\n\n            root: Root dataset storage directory. Default is '.data'.\n            exts: A tuple containing the extension to path for each language.\n            fields: A tuple containing the fields that will be used for data\n                in each language.\n            train: The prefix of the train data. Default: 'train'.\n            validation: The prefix of the validation data. Default: 'val'.\n            test: The prefix of the test data. Default: 'test'.\n            Remaining keyword arguments: Passed to the splits method of\n                Dataset.\n        \"\"\"\n        return super(Multi30k, cls).splits(\n            exts, fields, root, train, validation, test, **kwargs)\n\n\nclass IWSLT(TranslationDataset):\n    \"\"\"The IWSLT 2016 TED talk translation task\"\"\"\n\n    base_url = 'https://wit3.fbk.eu/archive/2016-01//texts/{}/{}/{}.tgz'\n    name = 'iwslt'\n    base_dirname = '{}-{}'\n\n    @classmethod\n    def splits(cls, exts, fields, root='.data',\n               train='train', validation='IWSLT16.TED.tst2013',\n               test='IWSLT16.TED.tst2014', **kwargs):\n        \"\"\"Create dataset objects for splits of the IWSLT dataset.\n\n        Arguments:\n\n            root: Root dataset storage directory. Default is '.data'.\n            exts: A tuple containing the extension to path for each language.\n            fields: A tuple containing the fields that will be used for data\n                in each language.\n            train: The prefix of the train data. Default: 'train'.\n            validation: The prefix of the validation data. Default: 'val'.\n            test: The prefix of the test data. Default: 'test'.\n            Remaining keyword arguments: Passed to the splits method of\n                Dataset.\n        \"\"\"\n        cls.dirname = cls.base_dirname.format(exts[0][1:], exts[1][1:])\n        cls.urls = [cls.base_url.format(exts[0][1:], exts[1][1:], cls.dirname)]\n        check = os.path.join(root, cls.name, cls.dirname)\n        path = cls.download(root, check=check)\n\n        train = '.'.join([train, cls.dirname])\n        validation = '.'.join([validation, cls.dirname])\n        if test is not None:\n            test = '.'.join([test, cls.dirname])\n\n        if not os.path.exists(os.path.join(path, train) + exts[0]):\n            cls.clean(path)\n\n        train_data = None if train is None else cls(\n            os.path.join(path, train), exts, fields, **kwargs)\n        val_data = None if validation is None else cls(\n            os.path.join(path, validation), exts, fields, **kwargs)\n        test_data = None if test is None else cls(\n            os.path.join(path, test), exts, fields, **kwargs)\n        return tuple(d for d in (train_data, val_data, test_data)\n                     if d is not None)\n\n    @staticmethod\n    def clean(path):\n        for f_xml in glob.iglob(os.path.join(path, '*.xml')):\n            print(f_xml)\n            f_txt = os.path.splitext(f_xml)[0]\n            with io.open(f_txt, mode='w', encoding='utf-8') as fd_txt:\n                root = ET.parse(f_xml).getroot()[0]\n                for doc in root.findall('doc'):\n                    for e in doc.findall('seg'):\n                        fd_txt.write(e.text.strip() + '\\n')\n\n        xml_tags = ['<url', '<keywords', '<talkid', '<description',\n                    '<reviewer', '<translator', '<title', '<speaker']\n        for f_orig in glob.iglob(os.path.join(path, 'train.tags*')):\n            print(f_orig)\n            f_txt = f_orig.replace('.tags', '')\n            with io.open(f_txt, mode='w', encoding='utf-8') as fd_txt, \\\n                    io.open(f_orig, mode='r', encoding='utf-8') as fd_orig:\n                for l in fd_orig:\n                    if not any(tag in l for tag in xml_tags):\n                        fd_txt.write(l.strip() + '\\n')\n\n\nclass WMT14(TranslationDataset):\n    \"\"\"The WMT 2014 English-German dataset, as preprocessed by Google Brain.\n\n    Though this download contains test sets from 2015 and 2016, the train set\n    differs slightly from WMT 2015 and 2016 and significantly from WMT 2017.\"\"\"\n\n    urls = [('https://drive.google.com/uc?export=download&'\n             'id=0B_bZck-ksdkpM25jRUN2X2UxMm8', 'wmt16_en_de.tar.gz')]\n    name = 'wmt14'\n    dirname = ''\n\n    @classmethod\n    def splits(cls, exts, fields, root='.data',\n               train='train.tok.clean.bpe.32000',\n               validation='newstest2013.tok.bpe.32000',\n               test='newstest2014.tok.bpe.32000', **kwargs):\n        \"\"\"Create dataset objects for splits of the WMT 2014 dataset.\n\n        Arguments:\n\n            root: Root dataset storage directory. Default is '.data'.\n            exts: A tuple containing the extensions for each language. Must be\n                either ('.en', '.de') or the reverse.\n            fields: A tuple containing the fields that will be used for data\n                in each language.\n            train: The prefix of the train data. Default:\n                'train.tok.clean.bpe.32000'.\n            validation: The prefix of the validation data. Default:\n                'newstest2013.tok.bpe.32000'.\n            test: The prefix of the test data. Default:\n                'newstest2014.tok.bpe.32000'.\n            Remaining keyword arguments: Passed to the splits method of\n                Dataset.\n        \"\"\"\n        return super(WMT14, cls).splits(\n            exts, fields, root, train, validation, test, **kwargs)\n", "path": "torchtext/datasets/translation.py"}], "after_files": [{"content": "import os\nimport xml.etree.ElementTree as ET\nimport glob\nimport io\n\nfrom .. import data\n\n\nclass TranslationDataset(data.Dataset):\n    \"\"\"Defines a dataset for machine translation.\"\"\"\n\n    @staticmethod\n    def sort_key(ex):\n        return data.interleave_keys(len(ex.src), len(ex.trg))\n\n    def __init__(self, path, exts, fields, **kwargs):\n        \"\"\"Create a TranslationDataset given paths and fields.\n\n        Arguments:\n            path: Common prefix of paths to the data files for both languages.\n            exts: A tuple containing the extension to path for each language.\n            fields: A tuple containing the fields that will be used for data\n                in each language.\n            Remaining keyword arguments: Passed to the constructor of\n                data.Dataset.\n        \"\"\"\n        if not isinstance(fields[0], (tuple, list)):\n            fields = [('src', fields[0]), ('trg', fields[1])]\n\n        src_path, trg_path = tuple(os.path.expanduser(path + x) for x in exts)\n\n        examples = []\n        with open(src_path) as src_file, open(trg_path) as trg_file:\n            for src_line, trg_line in zip(src_file, trg_file):\n                src_line, trg_line = src_line.strip(), trg_line.strip()\n                if src_line != '' and trg_line != '':\n                    examples.append(data.Example.fromlist(\n                        [src_line, trg_line], fields))\n\n        super(TranslationDataset, self).__init__(examples, fields, **kwargs)\n\n    @classmethod\n    def splits(cls, exts, fields, path=None, root='.data',\n               train='train', validation='val', test='test', **kwargs):\n        \"\"\"Create dataset objects for splits of a TranslationDataset.\n\n        Arguments:\n            path (str): Common prefix of the splits' file paths, or None to use\n                the result of cls.download(root).\n            root: Root dataset storage directory. Default is '.data'.\n            exts: A tuple containing the extension to path for each language.\n            fields: A tuple containing the fields that will be used for data\n                in each language.\n            train: The prefix of the train data. Default: 'train'.\n            validation: The prefix of the validation data. Default: 'val'.\n            test: The prefix of the test data. Default: 'test'.\n            Remaining keyword arguments: Passed to the splits method of\n                Dataset.\n        \"\"\"\n        if path is None:\n            path = cls.download(root)\n\n        train_data = None if train is None else cls(\n            os.path.join(path, train), exts, fields, **kwargs)\n        val_data = None if validation is None else cls(\n            os.path.join(path, validation), exts, fields, **kwargs)\n        test_data = None if test is None else cls(\n            os.path.join(path, test), exts, fields, **kwargs)\n        return tuple(d for d in (train_data, val_data, test_data)\n                     if d is not None)\n\n\nclass Multi30k(TranslationDataset):\n    \"\"\"The small-dataset WMT 2016 multimodal task, also known as Flickr30k\"\"\"\n\n    urls = ['http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/training.tar.gz',\n            'http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/validation.tar.gz',\n            'http://www.quest.dcs.shef.ac.uk/'\n            'wmt17_files_mmt/mmt_task1_test2016.tar.gz']\n    name = 'multi30k'\n    dirname = ''\n\n    @classmethod\n    def splits(cls, exts, fields, root='.data',\n               train='train', validation='val', test='test2016', **kwargs):\n        \"\"\"Create dataset objects for splits of the Multi30k dataset.\n\n        Arguments:\n\n            root: Root dataset storage directory. Default is '.data'.\n            exts: A tuple containing the extension to path for each language.\n            fields: A tuple containing the fields that will be used for data\n                in each language.\n            train: The prefix of the train data. Default: 'train'.\n            validation: The prefix of the validation data. Default: 'val'.\n            test: The prefix of the test data. Default: 'test'.\n            Remaining keyword arguments: Passed to the splits method of\n                Dataset.\n        \"\"\"\n        return super(Multi30k, cls).splits(\n            exts, fields, root, train, validation, test, **kwargs)\n\n\nclass IWSLT(TranslationDataset):\n    \"\"\"The IWSLT 2016 TED talk translation task\"\"\"\n\n    base_url = 'https://wit3.fbk.eu/archive/2016-01//texts/{}/{}/{}.tgz'\n    name = 'iwslt'\n    base_dirname = '{}-{}'\n\n    @classmethod\n    def splits(cls, exts, fields, root='.data',\n               train='train', validation='IWSLT16.TED.tst2013',\n               test='IWSLT16.TED.tst2014', **kwargs):\n        \"\"\"Create dataset objects for splits of the IWSLT dataset.\n\n        Arguments:\n\n            root: Root dataset storage directory. Default is '.data'.\n            exts: A tuple containing the extension to path for each language.\n            fields: A tuple containing the fields that will be used for data\n                in each language.\n            train: The prefix of the train data. Default: 'train'.\n            validation: The prefix of the validation data. Default: 'val'.\n            test: The prefix of the test data. Default: 'test'.\n            Remaining keyword arguments: Passed to the splits method of\n                Dataset.\n        \"\"\"\n        cls.dirname = cls.base_dirname.format(exts[0][1:], exts[1][1:])\n        cls.urls = [cls.base_url.format(exts[0][1:], exts[1][1:], cls.dirname)]\n        check = os.path.join(root, cls.name, cls.dirname)\n        path = cls.download(root, check=check)\n\n        train = '.'.join([train, cls.dirname])\n        validation = '.'.join([validation, cls.dirname])\n        if test is not None:\n            test = '.'.join([test, cls.dirname])\n\n        if not os.path.exists(os.path.join(path, train) + exts[0]):\n            cls.clean(path)\n\n        train_data = None if train is None else cls(\n            os.path.join(path, train), exts, fields, **kwargs)\n        val_data = None if validation is None else cls(\n            os.path.join(path, validation), exts, fields, **kwargs)\n        test_data = None if test is None else cls(\n            os.path.join(path, test), exts, fields, **kwargs)\n        return tuple(d for d in (train_data, val_data, test_data)\n                     if d is not None)\n\n    @staticmethod\n    def clean(path):\n        for f_xml in glob.iglob(os.path.join(path, '*.xml')):\n            print(f_xml)\n            f_txt = os.path.splitext(f_xml)[0]\n            with io.open(f_txt, mode='w', encoding='utf-8') as fd_txt:\n                root = ET.parse(f_xml).getroot()[0]\n                for doc in root.findall('doc'):\n                    for e in doc.findall('seg'):\n                        fd_txt.write(e.text.strip() + '\\n')\n\n        xml_tags = ['<url', '<keywords', '<talkid', '<description',\n                    '<reviewer', '<translator', '<title', '<speaker']\n        for f_orig in glob.iglob(os.path.join(path, 'train.tags*')):\n            print(f_orig)\n            f_txt = f_orig.replace('.tags', '')\n            with io.open(f_txt, mode='w', encoding='utf-8') as fd_txt, \\\n                    io.open(f_orig, mode='r', encoding='utf-8') as fd_orig:\n                for l in fd_orig:\n                    if not any(tag in l for tag in xml_tags):\n                        fd_txt.write(l.strip() + '\\n')\n\n\nclass WMT14(TranslationDataset):\n    \"\"\"The WMT 2014 English-German dataset, as preprocessed by Google Brain.\n\n    Though this download contains test sets from 2015 and 2016, the train set\n    differs slightly from WMT 2015 and 2016 and significantly from WMT 2017.\"\"\"\n\n    urls = [('https://drive.google.com/uc?export=download&'\n             'id=0B_bZck-ksdkpM25jRUN2X2UxMm8', 'wmt16_en_de.tar.gz')]\n    name = 'wmt14'\n    dirname = ''\n\n    @classmethod\n    def splits(cls, exts, fields, root='.data',\n               train='train.tok.clean.bpe.32000',\n               validation='newstest2013.tok.bpe.32000',\n               test='newstest2014.tok.bpe.32000', **kwargs):\n        \"\"\"Create dataset objects for splits of the WMT 2014 dataset.\n\n        Arguments:\n\n            root: Root dataset storage directory. Default is '.data'.\n            exts: A tuple containing the extensions for each language. Must be\n                either ('.en', '.de') or the reverse.\n            fields: A tuple containing the fields that will be used for data\n                in each language.\n            train: The prefix of the train data. Default:\n                'train.tok.clean.bpe.32000'.\n            validation: The prefix of the validation data. Default:\n                'newstest2013.tok.bpe.32000'.\n            test: The prefix of the test data. Default:\n                'newstest2014.tok.bpe.32000'.\n            Remaining keyword arguments: Passed to the splits method of\n                Dataset.\n        \"\"\"\n        return super(WMT14, cls).splits(\n            exts, fields, root, train, validation, test, **kwargs)\n", "path": "torchtext/datasets/translation.py"}]}