Skip to content

Commit

Permalink
fix dictionary load bug
Browse files Browse the repository at this point in the history
  • Loading branch information
NISHIMWE Lydia committed Sep 15, 2023
1 parent 3727be9 commit 9f8882b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/nllb/laser_distillation/laser_distillation_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ def __init__(self, args, config, src_dictionary, tgt_dictionary, num_tasks):

@classmethod
def setup_task(cls, args, **kwargs):
import pdb
pdb.set_trace()
config = json.load(open(args.configfile))
num_tasks = max([dataset["id"] for dataset in config["train"]]) + 1

Expand Down
3 changes: 2 additions & 1 deletion fairseq/data/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def unk_string(self, escape=False):

def add_symbol(self, word, n=1, overwrite=False):
"""Adds a word to the dictionary"""
if word in self.indices and not overwrite:
if word in self.indices and overwrite:
idx = self.indices[word]
self.count[idx] = self.count[idx] + n
return idx
Expand Down Expand Up @@ -251,6 +251,7 @@ def add_from_file(self, f):

for line in lines[indices_start_line:]:
try:

line, field = line.rstrip().rsplit(" ", 1)
if field == "#fairseq:overwrite":
overwrite = True
Expand Down

0 comments on commit 9f8882b

Please sign in to comment.