gen_wordcloud.py 文件源码

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

项目:es_email_intel 作者: xujun10110 项目源码 文件源码
def gen_wordcloud():

    then = common_functions.queryrange(1)

    body = '''{
        "size" : 10000,
        "query": {
            "constant_score": {
                "filter": {
                    "range": {
                        "epoch": {
                            "from": '''+then+'''
                        }
                    }
                }
            }
        }
    }'''

    text = common_functions.pull_mailtext_24hrs(es, es_collection_name, body, keywords_list).lower()

    print text
    print

    wc = WordCloud(background_color="white", max_words=40)
    fileloc = "/home/pierre/es_email_intel/wordcloud.png"
    try:
        wc.generate(text)
        wc.to_file(fileloc)
        print 'Finished!'
        return
    except:
        target = open(fileloc, 'w')
        target.truncate()
        target.close()
        print 'Except!'
        return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号