You need to sign in or sign up before continuing.
Commit 1ca075a2 authored by Ning Dong's avatar Ning Dong Committed by Facebook Github Bot
Browse files

Replace unknown word by original source word when empty string is given (#770)

Summary:
Pull Request resolved: https://github.com/pytorch/fairseq/pull/770

Without this change comment here https://fburl.com/w1cejgw9 is inconsistent with the implementation.

Reviewed By: xianxl

Differential Revision: D15582826

fbshipit-source-id: 16d8368560153b251beed8b290f51fcdd8a8faee
parent fa7791df
...@@ -84,7 +84,7 @@ def set_incremental_state(module, incremental_state, key, value): ...@@ -84,7 +84,7 @@ def set_incremental_state(module, incremental_state, key, value):
def load_align_dict(replace_unk): def load_align_dict(replace_unk):
if replace_unk is None: if replace_unk is None:
align_dict = None align_dict = None
elif isinstance(replace_unk, str): elif isinstance(replace_unk, str) and len(replace_unk) > 0:
# Load alignment dictionary for unknown word replacement if it was passed as an argument. # Load alignment dictionary for unknown word replacement if it was passed as an argument.
align_dict = {} align_dict = {}
with open(replace_unk, 'r') as f: with open(replace_unk, 'r') as f:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment