class_docstr: Defines a dataset for machine translation.
class_docstr_tok: ["Defines","a","dataset","for","machine","translation","."]
docstr: Create a TranslationDataset given paths and fields.
  
  Arguments:
      path: Common prefix of paths to the data files for both languages.
      exts: A tuple containing the extension to path for each language.
      fields: A tuple containing the fields that will be used for data
          in each language.
      Remaining keyword arguments: Passed to the constructor of
          data.Dataset.
docstr_tok: ["Create","a","TranslationDataset","given","paths","and","fields",".","Arguments",":","path",":","Common","prefix","of","paths","to","the","data","files","for","both","languages",".","exts",":","A","tuple","containing","the","extension","to","path","for","each","language",".","fields",":","A","tuple","containing","the","fields","that","will","be","used","for","data","in","each","language",".","Remaining","keyword","arguments",":","Passed","to","the","constructor","of","data.Dataset","."]
code: def __init__(self, path, exts, fields, **kwargs):
      """Create a TranslationDataset given paths and fields.
  
      Arguments:
          path: Common prefix of paths to the data files for both languages.
          exts: A tuple containing the extension to path for each language.
          fields: A tuple containing the fields that will be used for data
              in each language.
          Remaining keyword arguments: Passed to the constructor of
              data.Dataset.
      """
      if not isinstance(fields[0], (tuple, list)):
          fields = [("src", fields[0]), ("trg", fields[1])]
  
      src_path, trg_path = tuple(
          os.path.expanduser(path + x) for x in exts
      )
  
      examples = []
      with open(src_path) as src_file, open(trg_path) as trg_file:
          for src_line, trg_line in zip(src_file, trg_file):
              src_line, trg_line = src_line.strip(), trg_line.strip()
              if src_line != "" and trg_line != "":
                  examples.append(
                      data.Example.fromlist(
                          [src_line, trg_line], fields
                      )
                  )
  
      super(TranslationDataset, self).__init__(
          examples, fields, **kwargs
      )
  
file_path: decanlp/text/torchtext/datasets/translation.py
imports: import os
  import xml.etree.ElementTree
  import glob
  import io
  from ..None import data
label_desc: Use image node_id 2 to create a new TranslationDataset object from inherited base classes: data with example: obj = TranslationDataset(path, exts, fields)