Python production Tag Cloud

Source: Internet
Author: User
Tags thread zookeeper

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/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.