diff --git a/translate.py b/translate.py index 902212632b..b9c7f76a96 100755 --- a/translate.py +++ b/translate.py @@ -2,6 +2,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from itertools import repeat + from onmt.utils.logging import init_logger from onmt.utils.misc import split_corpus from onmt.translate.translator import build_translator @@ -17,7 +19,7 @@ def main(opt): translator = build_translator(opt, report_score=True) src_shards = split_corpus(opt.src, opt.shard_size) tgt_shards = split_corpus(opt.tgt, opt.shard_size) \ - if opt.tgt is not None else [None]*opt.shard_size + if opt.tgt is not None else repeat(None) shard_pairs = zip(src_shards, tgt_shards) for i, (src_shard, tgt_shard) in enumerate(shard_pairs):