How to implement an easy-to-use word cloud generation tool?

Time:2021-7-29

Creative background

It has always been a personal dream to generate a cool cloud picture at any time.

A long time ago, I wrote a simple version:http://houbb.github.io/tools/…

The effects are as follows:

How to implement an easy-to-use word cloud generation tool?

However, there are some small problems:

  1. Automatic word segmentation is not possible
  2. Cannot set font size based on word frequency

So I walked around GitHub and foundkumoThis is an open source tool,
The entry experience found that it takes more than 10 lines of code to realize the most basic cloud map.

This is not elegant, so I decided to implement a more easy-to-use version based on Kumo.

word-cloud

word-cloudIs a cloud map generation tool designed for Java.

characteristic

  • Minimalist API, one line of code to do everything
  • Support custom cloud background
  • Supports Chinese and English word segmentation, which is transparent to users by default
  • Support pause word filtering, which is transparent to users by default
  • Support various user-defined configurations

Change log

Quick start

Maven introduction

<dependency>
     <groupId>com.github.houbb</groupId>
     <artifactId>word-cloud</artifactId>
     <version>1.2.2</version>
</dependency>

use

Wordcloudhelper. Wordcloud ("the work is about an ancient abandoned Kingdom named holy nest buried under a declining town called detmouth. This kingdom was eroded and abandoned by the plague. The reason for abandonment is that the ancient god of light called radiant light can spread the plague through thought. The insects eroded by the plague will be dominated by instinct and lose their mind\ n" +
                "The master of this kingdom, the pale king, naturally will not sit idly by. In the abyss under the holy nest, he used another ancient power" void "to suppress the characteristics of light and created the container family. One of the selected containers was used to seal the plague and was named the empty knight. In order to stabilize the seal, the white king looked for three dreamers to further consolidate the seal. The names of the three dreamers were Catcher - lurian, mentor - monomon and beast - Hera. But then the pale King disappeared, and the power of the imperfect container became weaker and weaker, and finally controlled by the radiation. The protagonist will pass through all parts of the holy nest. In the resting place, we are helped by the believers who once radiated light and the only family left by the moth family, and have obtained the dream weapon - Dream nail, which is homologous with the power of radiation. Dream nail can read the inner thoughts of creatures, break the protection of dreamers, enter their dreams and kill dreamers. After killing the three dreamers and unlocking the seals, the optional outcomes are to reach the black egg temple in the cross road, defeat the empty knight, or go to the new place "divine residence" added in the "God seeker" update and challenge the holy nest pantheon. ");

effect:

How to implement an easy-to-use word cloud generation tool?

Support background

With the whale background, we can show the text in the form of images:

String imagePath = "backgrounds\\whale_small.png";
WordCloudHelper.wordCloud(text, "out_bg.png", imagePath);

The effects are as follows:

How to implement an easy-to-use word cloud generation tool?

Road-Map

  • [x] Default shape, picture.
  • [x] Import picture background
  • [] default font optimization
  • [] image centered

Open Source

Originally, I wrote this gadget for the purpose of self entertainment, but I feel that I should open source this application.

Because NokumoOpen source, there is no such tool.

Open source address:https://github.com/houbb/word-cloud

If you like, you might as well give a star to encourage the author.

I hope to witness the growth of the best cloud map tool with you.