WordCloud.jl - a word cloud generator in julia

Hi, I’m very happy to announce my first julia package WordCloud.jl here. Word cloud (tag cloud or wordle) is a novelty visual representation of text data. The importance of each word is shown with font size or color. WordCloud.jl has the following highlights:

  • Flexible Any mask, any color, any angle, adjustable filling rate. You can specify the initial position of some words. Or you can pin some words and adjust others, etc.
  • Fast 100% in Julia and efficient implementation based on Quadtree & gradient optimization. The advantage is more obvious when generating large images.
  • Exact Words with the same weight have the exact same size. The algorithm will never scale the word to fit the blank.

A example

using WordCloud
wc = wordcloud(
    process(open(pkgdir(WordCloud)*"/res/alice.txt"), stopwords=WordCloud.stopwords_en ∪ ["said"]), 
    mask = loadmask(pkgdir(WordCloud)*"/res/alice_mask.png", color="#faeef8"),
    colors = :Set1_5,
    angles = (0, 90),
    fillingrate = 0.7) |> generate!
paint(wc, "alice.png", ratio=0.5, background=outline(wc.mask, color="purple", linewidth=1))

alice

You can install WordCloud.jl with command import Pkg; Pkg.add("WordCloud"), and see showexample and runexample for more examples.

I am looking forward to your valuable suggestions. Thank you.

59 Likes

Beautiful

guxiang
Aha, I can reply to bypass the limit of one image.

3 Likes

3 Likes

Really cool! :tada: The fact that it is 100% Julia is awesome :julia: :wink:

6 Likes

Is there a way to export SVGs, ideally with clickable links?

3 Likes

Not yet, but relevant information can be obtained through getposition(wc), getangle(wc), getweight(wc) and getword(wc) :slightly_smiling_face:

4 Likes

Haha what a nice coincidence! I was just looking for a tool to make a word cloud for a presentation I will give in two weeks, and this is a nice timely surprise!

3 Likes

Ha ha, I hope it can help you :laughing:

2 Likes

SVG exporting is supported at v0.4.0:v: You just need to paint(wc, "filename.svg") or paintsvg(wc). While, this feature depends on Luxor v2.8.0 which may be released after Julia 1.6. Therefore, it’s not currently available via Pkg’s update.

6 Likes
1 Like

I’m looking forward to it. Thank you for your great work.

1 Like

Very good stuff. Would it be possible for someone to generate a word cloud for the Julia discourse repository?

1 Like

We need .txt or .html files as inputs. Running showexample(:juliadoc) in v0.4.0 can show the way to generate word cloud from julia’s html docs. Moreover, showexample(:fromweb) shows a example that generates a word cloud from online web page.

1 Like

Awesome Julia! I think this generator is more powerful than many other popular generators in other language ecosystems. Isn’t it?