When the list has not satisfied people's presentation of the information, the label cloud this way of presentation to meet people focus, highlighting trends, display preferences of the browsing needs, this article briefly describes the use of Python to generate tag cloud.
There are two ways of doing this:
1. Implement yourself (refer to http://www.i-alive.com/post/11/)
2. Use of existing libraries, mainly Pytagcloud
This paper is mainly to use Pytagcloud this library for the generation of tag clouds. You need to install it first, but if you don't have the Pygame and Simplejson two Python packages installed on your machine before, you'll need to download the installation first
them; After the installation of these three packages is complete, the use is very simple, the example code is as follows:
From Pytagcloud import create_tag_image,make_tags from
pytagcloud.lang.counter import get_tag_counts
TEXT = ' '
python (2) compiler (1) OLAP (1)
Recommender-system (2) crawler (1) python networkx (1))
Sinaweibo (1) Dremel (1) python-multi-thread (1) path (1)
mobile-internet (1) Hadoop HBase HDFS Zookeeper (1) meachine-learning (1)
similarity (1) HBase zookeeper (1) OpenSource (1)
python (2) python-multi-thread (1) mahout ITEMBASED-CF (1)
Levenshtein (1)
Auto-check (1) mahout itembased (1) Real-time data analysis
Python (2) Recommender-system (2) Python Recommender-system (1)) Real (1)
MapReduce Shuffle (1) video (1)
ant (1) Native Hadoop Libraries (1) Search (1)
bigtable (1) NC (1)
Recommender-system (1) bigdata (1) data-analysis (1)
"" '
tags = make_tags (get_tag_counts (TEXT), maxsize=150)
create_tag_image (tags, ' cloud_large.png ', size= (900 , 600))
After running, a cloud_large.png result file is generated in the current directory, with the following results:
In addition to generating pictures, Pytagcloud can also generate HTML-form tag clouds that can be used to interact with users and refer to Pytagcloud documents.
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/