reader.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:variational-text-tensorflow 作者: carpedm20 项目源码 文件源码
def _build_vocab(self, file_path, vocab_path):
    counter = Counter(self._read_text(file_path).split())

    count_pairs = sorted(counter.items(), key=lambda x: (-x[1], x[0]))
    words, _ = list(zip(*count_pairs))
    self.vocab = dict(zip(words, range(len(words))))

    save_pkl(vocab_path, self.vocab)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号