Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

pypm install cs.tags

How to install cs.tags

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install cs.tags
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1.1 Available View build log
Windows (64-bit)
0.1.1 Available View build log
Mac OS X (10.5+)
0.1.1 Available View build log
Linux (32-bit)
0.1.1 Available View build log
Linux (64-bit)
0.1.1 Available View build log
Lastest release
version 0.1.1 on Jan 5th, 2011


This package provides an engine that allows users to assign tags to items.

Clouds Engine

Use this package if you want to draw tag clouds or want to retrieve othe info related to tagging.

>>> from cs.tags.clouds import CloudsEngine

The clouds engine stores the tags that each user assigns to an item. Tags, users and items info is stored according a model in order to speed up retrieval. This mean that the data structures will conteins precalculated tag clouds prepeared to be drawed as fast as possible.

>>> clouds_engine = CloudsEngine()
>>> clouds_engine
<CloudsEngine tags=0>

In the beggining, the clouds engine doesn't contain anything:

>>> clouds_engine.getCloud()
([], 0, 0)

Each user can add to the engine his set of tags assignated to a given item. For this proposal, the update() method mantains the user-centric relations between items and tags:

>>> clouds_engine.update(item=1, user='Nando Quintana', tags=['simple','green','energy'])
>>> clouds_engine.update(item=2, user='Nando Quintana', tags=['complex','energy'])
>>> clouds_engine.update(item=3, user='Erral', tags=['mineral','sources'])
>>> clouds_engine.update(item=3, user='Nando Quintana', tags=['nuclear','power'])

The engine is now able of returning a tag cloud information, based on the updates mades until this moment:

>>> clouds_engine.getCloud()
([('energy', 2), ('complex', 1), ('green', 1), ('mineral', 1), ('nuclear', 1), ('power', 1), ('simple', 1), ('sources', 1)], 9, 8)

The getCloud() method returns this peculiar data structure. Showed info is composed by a tag lists and two numbers. The tag list is indeed a list of tuples, that contains the string tag and the weight in the cloud. Second number means the number of tagged items, and third, the number of tags in the clouds.

Optionally, you can give a maximum number of tag you want to include in your tag cloud:

>>> clouds_engine.getCloud(n=5)
([('energy', 2), ('complex', 1), ('green', 1), ('mineral', 1), ('nuclear', 1)], 9, 5)

If you want to draw a clouds of tags, posted by a single user, you can tell the getCloud() method which is the user you want to use as filter:

>>> clouds_engine.getCloud(users='Nando Quintana')
([('energy', 2), ('complex', 1), ('green', 1), ('nuclear', 1), ('power', 1), ('simple', 1)], 7, 6)

You can also filter the cloud by item:

>>> clouds_engine.getCloud(items=3, users='Nando Quintana', n=5)
([('nuclear', 1), ('power', 1)], 2, 2)

Or ask the engine a tag cloud in relation to a single item:

>>> clouds_engine.getCloud(items=3, n=5)
([('mineral', 1), ('nuclear', 1), ('power', 1), ('sources', 1)], 4, 4)
Implicit knowledge

There is more information you can extract from the engine. For example, you can draw a cloud with the tags that have been inserted in common items. Doing this, you can build implicit knowledge from the users tagging habits.

>>> clouds_engine.update(item=4, user='Nando Quintana', tags=['nuclear','power'])
>>> clouds_engine.update(item=5, user='Nando Quintana', tags=['nuclear','flower','power'])
>>> clouds_engine.update(item=5, user='Erral', tags=['black','power'])
>>> clouds_engine.getRelatedTags(tag='power')
([('nuclear', 3)], 3, 1)

Other info you can build from the tagging behaviour is the relation between items:

>>> clouds_engine.getRelatedItems(item=3)
([(4, 2), (5, 2)], 4, 2)

So in this example, item 3 has 2 tags in common wiht item 4, and other 2 wich item 5.

As in the case of tags and items, you can also discover the implicit relations between users, according to the tagging history:

>>> clouds_engine.getRelatedUsers(user='Erral')
([('Nando Quintana', 1)], 1, 1)

The results show that Erral and Nando Quintana have a tag in common.

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.