crawl_portrait_tweets.py 文件源码

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

项目:aurora 作者: carnby 项目源码 文件源码
def load_models(self):
        now = datetime.now()
        self.rec_candidates = []

        if self.last_model_update is None or (now - self.last_model_update).days >= 1:
            print('loading model', now)
            model_path = '{0}/it-topics'.format(settings.PORTRAIT_FOLDER)
            lda_filename = os.readlink('{0}/current_lda_model.gensim'.format(model_path))

            self.lda_model = gensim.models.ldamulticore.LdaMulticore.load(lda_filename)
            self.topic_graph = nx.read_gpickle('{0}/current_topic_graph.nx'.format(model_path))

            with gzip.open('{0}/current_candidates.json.gz'.format(model_path), 'rt') as f:
                self.rec_candidates = json.load(f)
                print('loaded', len(self.rec_candidates), 'candidates')

            self.last_model_update = datetime.now()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号