Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guo-yong-zhi/wordcloud.jl
word cloud generator in julia
https://github.com/guo-yong-zhi/wordcloud.jl
collision-detection julia layout-algorithm nlp packing-algorithm visualization wordcloud
Last synced: 14 days ago
JSON representation
word cloud generator in julia
- Host: GitHub
- URL: https://github.com/guo-yong-zhi/wordcloud.jl
- Owner: guo-yong-zhi
- License: gpl-3.0
- Created: 2019-09-27T07:54:28.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T07:47:34.000Z (15 days ago)
- Last Synced: 2024-10-29T08:29:07.065Z (15 days ago)
- Topics: collision-detection, julia, layout-algorithm, nlp, packing-algorithm, visualization, wordcloud
- Language: Julia
- Homepage:
- Size: 6.96 MB
- Stars: 109
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#
[WordCloud.jl](https://github.com/guo-yong-zhi/WordCloud.jl)
![juliadoc](res/juliadoc.png)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://guo-yong-zhi.github.io/WordCloud.jl/dev) [![CI](https://github.com/guo-yong-zhi/WordCloud.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/guo-yong-zhi/WordCloud.jl/actions/workflows/ci.yml) [![CI-nightly](https://github.com/guo-yong-zhi/WordCloud.jl/actions/workflows/ci-nightly.yml/badge.svg)](https://github.com/guo-yong-zhi/WordCloud.jl/actions/workflows/ci-nightly.yml) [![codecov](https://codecov.io/gh/guo-yong-zhi/WordCloud.jl/branch/master/graph/badge.svg?token=2U0X769Z51)](https://codecov.io/gh/guo-yong-zhi/WordCloud.jl) [![DOI](https://zenodo.org/badge/211266031.svg)](https://zenodo.org/badge/latestdoi/211266031)
Word cloud (tag cloud or wordle) is a novelty visual representation of text data. The importance of each word is shown with its font size, position, or color. `WordCloud.jl` is an ideal tool in the [Julia language](https://julialang.org/) for creating word clouds, offering several key benefits:
* ***Flexible*** - You have control over every aspect of generating a word cloud. You can customize the shape, color, angle, position, distribution, density, and spacing to align with your preferences and artistic style.
* ***Faithful*** - This visualization solution guarantees precise results. Each word appears only once, and its font size is determined solely by the provided weight. Words are never repeated or shrunk artificially to fill empty spaces.
* ***Efficient*** - It utilizes intelligent strategies and efficient nesting algorithms, implemented entirely in Julia (see [Stuffing.jl](https://github.com/guo-yong-zhi/Stuffing.jl)). As a result, it can easily generate high-resolution word clouds.
[✨ Go to the gallery ✨](https://github.com/guo-yong-zhi/WordCloud-Gallery/blob/main/README.md)
[🌐 Try the online generator 🌐](https://mybinder.org/v2/gh/guo-yong-zhi/pluto-on-binder/master?urlpath=pluto/open?url=https%3A%2F%2Fraw.githubusercontent.com%2Fguo-yong-zhi%2FWordCloud.jl%2Fmaster%2FWordCloudApp.jl) (a bit slow)
# Installation
```julia
import Pkg; Pkg.add("WordCloud")
```
# Basic Usage
```julia
using WordCloud
using Random
words = [randstring(rand(1:8)) for i in 1:300]
weights = randexp(length(words))
wc = wordcloud(words, weights)
generate!(wc)
paint(wc, "random.svg")
```
Other input types are also supported:
```julia
wc = wordcloud("It's easy to generate word clouds") |> generate! # from a string
```
```julia
wc = wordcloud(open(pkgdir(WordCloud)*"/res/alice.txt")) |> generate! # from a file
```
```julia
wc = wordcloud(["中文", "需要", "提前", "分词"]) |> generate! # from a list
```
```julia
wc = wordcloud(["the"=>1.0, "to"=>0.51, "and"=>0.50]) |> generate! # from pairs or a dict
```
And you can get the word cloud picture in one step:
```julia
paintcloud("obtain the final picture directly")
```
# Advanced Usage
```julia
using WordCloud
textfile = pkgdir(WordCloud)*"/res/alice.txt"
maskfile = pkgdir(WordCloud)*"/res/alice_mask.png"
wc = wordcloud(
open(textfile),
stopwords_extra = ["said"],
maxnum = 500,
mask = maskfile,
maskcolor = "#faeef8",
outline = 4,
linecolor = "purple",
colors = :Set1_5,
angles = (0, 90),
fonts = "Tahoma",
density = 0.55,
spacing = 3,) |> generate!
paint(wc, "alice.png")
```
*try `runexample(:alice)` or `showexample(:alice)`*
[![alice](res/alice.png)](./examples/alice.jl)
# More Examples
## Gathering style
[![gathering](res/gathering.png)](./examples/gathering.jl)
*try `runexample(:gathering)` or `showexample(:gathering)`*
## Recolor
[![recolor](res/recolor.png)](./examples/recolor.jl)
*try `runexample(:recolor)` or `showexample(:recolor)`*
## Semantic
[![semantic](res/semantic.png)](./examples/semantic.jl)
*try `runexample(:semantic)` or `showexample(:semantic)`*
The variable `WordCloud.EXAMPLES` holds all available examples.# About Implementation
WordCloud.jl stands out from other tools due to its unique approach based on image local gradient optimization. Unlike conventional algorithms, WordCloud.jl utilizes a non-greedy algorithm that enables words to be [repositioned](res/animation2.gif) even after their initial placement. This dynamic adjustment process provides unparalleled freedom in assigning words to any desired position, irrespective of potential overlaps. Furthermore, it eliminates the necessity of scaling words during the adjustment phase. This ingenious design choice maximizes the generator's flexibility, opening up boundless possibilities for customization. For a more detailed understanding of the algorithm, you can refer to the [Stuffing.jl - Algorithm Description](https://github.com/guo-yong-zhi/Stuffing.jl#algorithm-description).
* [x] 权重计算和单词位置初始化
* [x] 基于四叉树(层次包围盒)的碰撞检测
* [x] 根据局部灰度梯度平移单词(训练迭代)
* [x] 引入动量加速训练
* [x] 分代检测优化性能(for pairwise trainer)
* [x] 区域四叉树批量碰撞检测
* [x] LRU优化性能(for element-wise trainer)
* [x] 控制字体大小和填充密度的策略
* [x] 使用重新放置策略跳出局部最优
* [x] 使用缩放策略降低训练难度
* [x] 训练失败检测和提前中断
* [x] 主题配色等
* [x] 并行计算# Other word cloud generators
* [word_cloud (Python)](https://github.com/amueller/word_cloud)
* [d3-cloud](https://github.com/jasondavies/d3-cloud)
* [wordcloud (HTML5)](https://github.com/timdream/wordcloud)
* [swcv](https://github.com/spupyrev/swcv)
* [Wordle](http://static.mrfeinberg.com/bv_ch03.pdf)
* [Semantic Word Clouds with Background Corpus Normalization and t-distributed Stochastic Neighbor Embedding](https://arxiv.org/pdf/1708.03569.pdf)
* [An Evaluation of Semantically Grouped Word Cloud Designs](https://www.semanticscholar.org/paper/An-Evaluation-of-Semantically-Grouped-Word-Cloud-Hearst-Pedersen/ddae6a380123988f578433ae103393e255c0b4d1)