In short we can said that , the interface of the application is in the image below.
Word clouds presents the text, the text in the presentation file, the text in the Word file, the text in the pdf file and even the text in the notebook by distributing the words in the shape we want. Of course, the words are distributed in accordance with the shape. There are a lot of possibilities in Word clouds, for example, you can make the shape as determined by them or by opening the shape you want, but do not say that you are trying some shapes, because if the size of the text is small, it does not fill the shape, you can adjust its size from the line just above the shape to fill it. As you increase the size, the shape will fill up.
How is it imported?
Let’s test our application with a sentence as an example.
input = ‘On Kubilay s medium page, we learn how to create a word cloud with Kubilay. A little below you will see a result according to this paragraph. ‘
Input can be a sentence or paragraph dataset whatever you want.
In addition, you can use this parameters :
- background_color = Color of background
- width = width size of the output
- height = height size of the output
- max_words = The maximum number of unique words used
- stopwords = stopword list
- max_font_size = Maximum font size
- random_state = To ensure that random numbers are generated in the same order, so the results will be the same even if generated several times
Add Custom Mask
You can add a mask for the word cloud. You can use any image you want for masking, but there is an important point you need to know.
Note that the background of the image used must be white.
Also, the background cannot be transparent (transparent colors will be considered black.)
For example, we want to use this item for masking. First we have to import it.
our_mask = np.array(Image.open(‘mask_oval.png’))
cloud = WordCloud(background_color=”white”, mask = our_mask).generate(input)
#second way to use it.
cloud = WordCloud(background_color=”white”, mask = np.array(Image.open(‘mask_oval.png’))).generate(input)
After running the code we will get a result like this. (Images taken from https://amueller.github.io/word_cloud/auto_examples/masked.html)