def load_dictionary(cls, filename): """Load the dictionary from the filename Args: filename (str): the filename """ if filename.endswith('.txt'): return Dictionary.load(filename) else: return Dictionary.load_json(filename)
def load_dictionary(cls, filename): """Load the dictionary from the filename Args: filename (str): the filename """ is_sbt = str.startswith(os.path.basename(filename), 'sbt') if is_sbt: return SBTDictionary.load_json(filename) else: return Dictionary.load_json(filename)
def load_dictionary(cls, filename): """Load the dictionary from the filename Args: filename (str): the filename """ if filename.endswith('.txt'): return Dictionary.load(filename) else: is_bpe = os.path.basename(filename).split('.')[-3] == 'bpe' if is_bpe: return RetrievalDictionary.load_json(filename) else: return Dictionary.load_json(filename)