tasks.py 文件源码

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

项目:QProb 作者: quant-trade 项目源码 文件源码
def full_wordcloud():
    """
    Generates wordcloud for the site.
    """
    text = ""
    try:
        posts = Post.objects.filter().values("content")
        for post in posts:
            text += post["content"] + " "

        text = words_wo_stopwords(text=text)
        word_cloud = WordCloud(max_font_size=40, background_color="rgba(255, 255, 255, 0)", width=350, height=600, mode="RGBA").generate(text)
        fig = plt.figure(frameon=False)
        fig.patch.set_visible(False)
        ax = fig.add_axes([0, 0, 1, 1])
        ax.axis('off')
        ax.imshow(word_cloud, interpolation='bilinear')
        plt.savefig(join(settings.STATIC_ROOT, 'images', 'wordcloud.png'))
        plt.close()
    except Exception as err:
            print(err)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号