diff --git a/preprocess.py b/preprocess.py index ff9f119..3f2d0cf 100644 --- a/preprocess.py +++ b/preprocess.py @@ -8,7 +8,7 @@ def read_instances_from_file(inst_file, max_sent_len, keep_case): word_insts = [] trimmed_sent_count = 0 - with open(inst_file) as f: + with open(inst_file, encoding='utf-8') as f: for sent in f: if not keep_case: sent = sent.lower() diff --git a/translate.py b/translate.py index f062b5b..9663280 100644 --- a/translate.py +++ b/translate.py @@ -56,7 +56,7 @@ def main(): translator = Translator(opt) - with open(opt.output, 'w') as f: + with open(opt.output, 'w', encoding='utf-8') as f: for batch in tqdm(test_loader, mininterval=2, desc=' - (Test)', leave=False): all_hyp, all_scores = translator.translate_batch(*batch) for idx_seqs in all_hyp: