Generating Word Clouds using Python

4+
Source: wordclouds.com datamahadev

WORD CLOUDS / TEXT CLOUDS 

Searching for important keywords in the entire article or post is quite a difficult job, but no more, a word cloud is here to save your day.

A word cloud (also known as, Text Cloud) is simply a representation of the importance of different words in the body of text, the more a specific word appears in a source of textual data the larger and bolder it appears in the world cloud.

Well, representing research data using word cloud could be plus point, because they help engage the audience as it is fast and gives all the important keywords in one place.

Word clouds present a low budget substitute for analyzing text from on-line surveys. Primarily, word clouds generators work by breaking the text down into element words and enumeration how often they seem to appear within the body of the text.

Not only this, but Visual representation of data as a Word cloud also tends to leave a strong impact and generates interest amongst the audience.

Here, is a word cloud that is created from text extracted from Wikipedia.

Installation:

We need two packages for creating a word cloud.

1) Installing the Wikipedia package

2) Installing the word cloud package

Note: Please ensure that packages such as re (Regular expression operations), NumPy, PIL (pillow), and matplotlib are pre-installed. All these packages are already installed in Google Colab Notebook.

Code

1) First of all, importing all the necessary libraries like a word cloud, Wikipedia, re (Regular expression operations), NumPy, PIL (pillow) and matplotlib.

2) Now for our textual data, we can search for a topic in Wikipedia and then extract the same. Once our data is extracted, we can clean it and make it fit for making a word cloud. We can also use a PDF file or any other text document file to create a word cloud by simply uploading it in our notebook using files.upload() function.

3) Finally, we are all set for making our word cloud using the WordCloud function.

OUTPUT:

C:\Users\Hp\Desktop\data science\Word_cloud.png

Making Word cloud more attractive

We can make word cloud more attractive by giving it a shape of heart, bulb, cloud, or thumbs up, etc. All we have to do is provide an image in which we have to mask our word cloud.

OUTPUT:

C:\Users\Hp\Desktop\data science\design_cloud.png

Here is our word cloud. Well, you can customize it according to your preferences like you can vary background, colors, and shapes.

Congo, now you know how to make a word cloud. You can use them while presenting it to your client and other documents like school/college assignments as a visual aid. 

Github Link: https://github.com/Sid-Yo/Word-Cloud

About the author:

Siddhant Srivastava is a Data Science Enthusiast who has completed IBM Data Science Professional certification and enjoys using his skills to contribute to the exciting technological advances that happen in the Data Sciences field. He is currently pursuing a Bachelor’s Degree in Electronics and Communication, he is obsessed with all tech-related things and spends his free time exploring new data sets.

close
4+

You may also like...

1 Response

  1. Debjyoti Banerjee says:

    The second wordcloud which is in the shape of bulb is really amazing..

    0

Leave a Reply

Your email address will not be published. Required fields are marked *

DMCA.com Protection Status