wordcloud源码阅读2——Cython

上一节中,IntegralOccupancyMap()函数用来确定单词位置,其中调用了query_integral_image()方法。而query_integral_image是用来Cython。下边介绍Cython。 Cython介绍 Cython 的本质可以总结如下:Cython 是包含C 数据类型的Python。 Cython可以将Python代码编译成动态链接库,在某些情况下,可以极大提高Python程序的运行效率。 ...

2018-04-17 · 2 分钟 · 958 字 · Niuhe

wordcloud源码阅读1——初探

wordcloud是python用来生成词云的第三方库,github地址是word_cloud 下载源码: git clone https://github.com/amueller/word_cloud 然后,直接看最老的版本,有精力的话看完最老版本可以再看最新的版本。 git tag git checkout 1.2.1 现在我们的目录结构如下: 可以看到,核心代码都在wordcloud目录下: wordcloud项目主要用了以下第三方库: Numpy PIL Cython 储备知识: ...

2018-04-16 · 2 分钟 · 607 字 · Niuhe

WordCloud文档中文翻译

Python模块wordcloud参考文档的中文翻译 官网链接:wordcloud api reference Github链接:wordcloud 所有函数均封装在WordCloud类里: WordCloud([…]) 生成并绘制WordCloud对象 ImageColorGenerator(image) 词云颜色生成器(基于图片颜色) random_color_func([]) 词云颜色随机生成 wordcloud.WordCloud class wordcloud.WordCloud(font_path=None, width=400, height=200, margin=2, ranks_only=None, prefer_horizontal=0.9, mask=None, scale=1, color_func=None, max_words=200, min_font_size=4, stopwords=None, random_state=None, background_color='black', max_font_size=None, font_step=1, mode='RGB', relative_scaling=0.5, regexp=None, collocations=True, colormap=None, normalize_plurals=True) 参数: font_path : string 需要使用的字体路径(支持OTF和TTF)。Linux系统上默认指向DroidSansMono路径。若使用其他操作系统或者没有DroidSansMono字体,需要指定字体路径。 ...

2018-04-08 · 6 分钟 · 2588 字 · Niuhe