Skip to content

Commit

Permalink
fix dict order (facebookresearch#5109)
Browse files Browse the repository at this point in the history
  • Loading branch information
vineelpratap authored May 19, 2023
1 parent 5ecbbf5 commit bfd9dc6
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
Trie,
)
from flashlight.lib.text.dictionary import create_word_dict, load_words
from flashlight.lib.text.dictionary import Dictionary as flDictionary
except ImportError:
warnings.warn(
"flashlight python bindings are required to use this functionality. "
Expand Down Expand Up @@ -102,8 +103,9 @@ def __init__(self, cfg: FlashlightDecoderConfig, tgt_dict: Dictionary) -> None:
else:
assert self.unitlm, "Lexicon-free decoding requires unit LM"

d = {w: [[w]] for w in tgt_dict.symbols}
self.word_dict = create_word_dict(d)
self.word_dict = flDictionary()
for sym in tgt_dict.symbols:
self.word_dict.add_entry(sym, tgt_dict.index(sym))
self.lm = KenLM(cfg.lmpath, self.word_dict)
self.decoder_opts = LexiconFreeDecoderOptions(
beam_size=cfg.beam,
Expand Down

0 comments on commit bfd9dc6

Please sign in to comment.