def compile_files(raw_dir, raw_files, tag):
  """Compile raw files into a single file for each language.

  Args:
    raw_dir: Directory containing downloaded raw files.
    raw_files: Dict containing filenames of input and target data.
      {"inputs": list of files containing data in input language
       "targets": list of files containing corresponding data in target language
      }
    tag: String to append to the compiled filename.

  Returns:
    Full path of compiled input and target files.
  """
  tf.logging.info("Compiling files with tag %s." % tag)
  filename = "%s-%s" % (_PREFIX, tag)
  input_compiled_file = os.path.join(raw_dir, filename + ".lang1")
  target_compiled_file = os.path.join(raw_dir, filename + ".lang2")

  with tf.gfile.Open(input_compiled_file, mode="w") as input_writer:
    with tf.gfile.Open(target_compiled_file, mode="w") as target_writer:
      for i in range(len(raw_files["inputs"])):
        input_file = raw_files["inputs"][i]
        target_file = raw_files["targets"][i]

        tf.logging.info("Reading files %s and %s." % (input_file, target_file))
        write_file(input_writer, input_file)
        write_file(target_writer, target_file)
  return input_compiled_file, target_compiled_file
def compile_files ( raw_dir , raw_files , tag ) : tf . logging . info ( "Compiling files with tag %s." % tag ) filename = "%s-%s" % ( _PREFIX , tag ) input_compiled_file = os . path . join ( raw_dir , filename + ".lang1" ) target_compiled_file = os . path . join ( raw_dir , filename + ".lang2" ) with tf . gfile . Open ( input_compiled_file , mode = "w" ) as input_writer : with tf . gfile . Open ( target_compiled_file , mode = "w" ) as target_writer : for i in range ( len ( raw_files [ "inputs" ] ) ) : input_file = raw_files [ "inputs" ] [ i ] target_file = raw_files [ "targets" ] [ i ] tf . logging . info ( "Reading files %s and %s." % ( input_file , target_file ) ) write_file ( input_writer , input_file ) write_file ( target_writer , target_file ) return input_compiled_file , target_compiled_file
Compile raw files into a single file for each language.

  Args:
    raw_dir: Directory containing downloaded raw files.
    raw_files: Dict containing filenames of input and target data.
      {"inputs": list of files containing data in input language
       "targets": list of files containing corresponding data in target language
      }
    tag: String to append to the compiled filename.

  Returns:
    Full path of compiled input and target files.