In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces python how to generate word cloud map, the article is very detailed, has a certain reference value, interested friends must read it!
The generated word cloud image is as follows:
Install wordcloud,jieba, and install other packages by yourself:
Conda install-c conda-forge wordcloud
Conda install-c conda-forge jieba
Note: conda-forge is an organization of github that provides conda recipes libraries, which are interrelated things that can be packaged together. The specific usage is as above, first add conda-forge, and then install the required toolkit. This is the most recommended way to install the package, because it is the first choice for the community to use a package, version relevance and so on are tested.
The code example is as follows:
1. Import the libraries used, and see the notes for the role of each library.
two。 Read the file to be analyzed and preprocess the text.
Note: an error was encountered when opening the file, as follows, pay attention to the writing of open.
You can avoid similar errors by specifying the type of encoding when you open the file, as follows.
Fn=open ('ana_test.txt',encoding='utf-8')
3. The text is segmented and the result is put into object_list, using a user-defined dictionary.
4. Word frequency statistics, get the top 20 highest frequency words and output
5. Word frequency display, the image can be set to your favorite style.
6. Word cloud image display: see the annotation steps, generate word cloud from the dictionary (word frequency statistics), establish a color scheme from the background map, and set the word cloud color to the background map scheme to display the word cloud image.
7. Output result diagram, as follows:
The above is all the content of the article "how to generate word Cloud Picture by python". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.