Ejemplo n.º 1
0
def get_all_comments_wordcloud():
    content = ''
    for comment in Comment.select():
        content += comment.content + '\n'
    wordcloud = WordCloud(font_path=FONT_DIR + '/NotoSansCJKsc-Regular.otf',
                          width=7200,
                          height=2400,
                          stopwords=get_stopwords_set(),
                          background_color='white',
                          collocations=False)
    # 使用jieba分词的默认精确模式
    wordcloud.generate(' '.join(jieba.lcut(content)))
    wordcloud.to_file(IMAGE_DIR + '/mi10_all_comments_wordcloud.png')
Ejemplo n.º 2
0
def get_non_five_star_comments_wordcloud():
    content = ''
    for comment in Comment.select().where((Comment.star.in_([1, 2, 3, 4]))):
        content += comment.content + '\n'
        if comment.after_content is not None:
            content += comment.after_content + '\n'
    wordcloud = WordCloud(font_path=FONT_DIR + '/NotoSansCJKsc-Regular.otf',
                          width=4000,
                          height=2400,
                          stopwords=get_stopwords_set(),
                          background_color='white',
                          collocations=False)
    # 使用jieba分词的默认精确模式
    wordcloud.generate(' '.join(jieba.lcut(content)))
    wordcloud.to_file(IMAGE_DIR + '/mi10_non_five_star_comments_wordcloud.png')