__init__.py 文件源码

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

项目:all2vec 作者: iheartradio 项目源码 文件源码
def save(self, folder):
        """Save object and return corresponding files."""
        if not os.path.exists(folder):
            os.makedirs(folder)
        files = []
        # annoy objects can't be pickled, so save these separately
        for k, v in self._annoy_objects.items():
            annoy_filepath = os.path.join(folder, '{}.ann'.format(k))
            v._ann_obj.save(annoy_filepath)
            files.append(annoy_filepath)
        pickle_filepath = os.path.join(folder, 'object.pickle')
        with open(pickle_filepath, 'wb') as handle:
            dill.dump(self, handle)
        files.append(pickle_filepath)

        # write entity types
        enttypes = self.get_entity_types()

        info_file = os.path.join(folder, 'entity_info.json')
        with open(info_file, 'w') as handle:
            json.dump(enttypes, handle)
        files.append(info_file)
        return files
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号