def write_command_file(self, data_obj, alignments_file):
        command_name = os.path.join(self.tmp_dir, 'extract_phrases.'+self.time_stamp+'.sh')
        command = open(command_name, 'w')
        # cd to the dir of the script (it doesn't work from any other places because of gzip)
        # TODO: what's the problem with gzip?
        command.write(self.tmp_dir % "CUR_DIR=$PWD\ncd %s\n")
        # extract phrases
        command.write('%s/scripts/generic/extract-parallel.perl 1 split "sort    " %s/bin/extract %s %s %s %s/extract.%s 5 orientation --model wbe-msd --GZOutput\n' % (self.moses_dir, self.moses_dir, data_obj['target_file'], data_obj['source_file'], alignments_file, self.tmp_dir, self.time_stamp))

        # score phrase table halves
        command.write('%s/bin/score extract.%s.sorted.gz %s.f2e %s/phrase-table.%s.half.f2e.gz --GoodTuring  2>> /dev/stderr\n' % (self.moses_dir, self.time_stamp, self.lex_prob, self.tmp_dir, self.time_stamp))
        command.write('%s/bin/score extract.%s.inv.sorted.gz %s.e2f %s/phrase-table.%s.half.e2f.gz --Inverse  2>> /dev/stderr\n' % (self.moses_dir, self.time_stamp, self.lex_prob, self.tmp_dir, self.time_stamp))

        # sort phrase table halves
        command.write('gunzip -c %s/phrase-table.%s.half.f2e.gz | LC_ALL=C sort | gzip -c > %s/phrase-table.%s.half.f2e.sorted.gz\n' % (self.tmp_dir, self.time_stamp, self.tmp_dir, self.time_stamp))
        command.write('gunzip -c %s/phrase-table.%s.half.e2f.gz | LC_ALL=C sort | gzip -c > %s/phrase-table.%s.half.e2f.sorted.gz\n' % (self.tmp_dir, self.time_stamp, self.tmp_dir, self.time_stamp))

        # consolidate halves
        command.write('%s/bin/consolidate %s/phrase-table.%s.half.f2e.sorted.gz %s/phrase-table.%s.half.e2f.sorted.gz /dev/stdout --GoodTuring %s/phrase-table.%s.half.f2e.gz.coc | gzip -c > %s/phrase-table.%s.gz\n' % (self.moses_dir, self.tmp_dir, self.time_stamp, self.tmp_dir, self.time_stamp, self.tmp_dir, self.time_stamp, self.tmp_dir, self.time_stamp))

        command.write('mkdir -p %s/binarized\n' % self.tmp_dir)
        # binarize the phrase table
        command.write('gzip -cd %s/phrase-table.%s.gz | LC_ALL=C sort -T %s/binarized | %s/bin/processPhraseTable -ttable 0 0 - -nscores 4 -out %s/binarized/phrase-table.%s\n' % (self.tmp_dir, self.time_stamp, self.tmp_dir, self.moses_dir, self.tmp_dir, self.time_stamp))
        command.write('rm %s/phrase-table.%s.half.*\n' % (self.tmp_dir, self.time_stamp))
        # return back to where the script was run from
        command.write('cd $CUR_DIR\n')
        command.close()
        phrase_table = os.path.join(self.tmp_dir, 'binarized/phrase-table.{}'.format(self.time_stamp))
        return command_name, phrase_table

    # write Moses config for the current run
dataset/ETHPy150Open qe-team/marmot/marmot/representations/segmentation_representation_generator.py/SegmentationRepresentationGenerator.write_command_file/swapped operands of `%`