Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read and write files using UTF-8 encoding #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down