def load(cls, filename):
with open(filename, "r") as f:
info_dict = pickle.load(f)
v = Vocab()
v.tokens = info_dict["tokens"]
v.strings = info_dict["strings"]
v.unk = info_dict["unk"]
v.START_TOK = info_dict["START_TOK"]
v.END_TOK = info_dict["END_TOK"]
defaultf = (lambda :v.unk) if (v.unk is not None) else Token.not_found
v.s2t = defaultdict(defaultf, info_dict["s2t"])
v.i2t = defaultdict(defaultf, info_dict["i2t"])
return v
评论列表
文章目录