上下文

看看Wordle: http://www.wordle.net/ 它比我见过的任何其他词云生成器都好看得多 注意:源代码不可用-阅读常见问题:http://www.wordle.net/faq#code

我的问题

有没有一种算法可以做到Wordle所做的呢? 如果没有,有什么替代方案可以产生类似的输出?

我为什么问这个问题

只是好奇 想要学习


当前回答

Tim Dream制作了一个非常不错的JavaScript库:

https://github.com/timdream/wordcloud2.js/blob/gh-pages/API.md

它可以在画布上或HTML标签上创建文字云,并提供许多选项来修改结果。它非常接近wordle的输出。

其他回答

我正在研究WordCram,一个用于制作词云的处理库。它受到Wordle的很大影响,并被上面链接的相同的PDF aeby告知。它为你处理碰撞检测,让你专注于你想要的文字布局,颜色,旋转等。

我创建了一个Silverlight组件,它使用Jonathan在这里建议的算法。源代码和示例项目都可以在我的博客上找到:

http://whydoidoit.com

我的云可以让你根据不同的权重为单词着色和大小,它支持单词选择(从坐标)和选中的单词高亮显示。源代码是您的,您可以根据需要使用。

这是Python 3中wordle的另一个端到端实现,主要基于Jonathan Feinberg的初始轮廓(四叉树、螺旋等)。

代码(注释,详细的ReadMe文件)在这个Github库中免费提供,这是一个用代码创建的示例wordle。

I've implemented a word cloud generator called WordCloud.jl in Julia language. A brief description about its algorithm can be found here. Unlike most other implementations, I designed it based on gradient optimization. It’s a non-greedy algorithm in which words can be further moved after they are positioned. Thus the size of the words and the shape and size of the background mask can be kept unchanged in the generation process. This makes the outputs more accurate and easy to customize. Furthermore, we can also generate some fancy outputs like these: Comparison of Obama's and Trump's inaugural address and Wikipedia: Julia

这是一个非常好的javascript代码,来自Jason Davies,它使用了d3。你甚至可以使用web字体。

演示: http://www.jasondavies.com/wordcloud/

Github: https://github.com/jasondavies/d3-cloud