peruse.py 文件源码

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

项目:TwitterPeruser 作者: ilyauts 项目源码 文件源码
def generateWordCloud(text):
    # read the mask / color image
    # taken from http://jirkavinse.deviantart.com/art/quot-Real-Life-quot-Alice-282261010
    d = path.dirname(__file__)

    cloud_coloring = np.array(Image.open(path.join(d, "us-mask-white.png")))
    stopwords = set(STOPWORDS)
    stopwords.add("said")

    wc = WordCloud(background_color="black", max_words=2000, mask=cloud_coloring,
                   stopwords=stopwords, max_font_size=40, random_state=42)
    # generate word cloud
    wc.generate(text)

    # create coloring from image
    image_colors = ImageColorGenerator(cloud_coloring)

    # show
    plt.imshow(wc)
    plt.axis("off")
    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号