{ "info": { "author": "Thomas Mansencal", "author_email": "thomas.mansencal@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Utilities" ], "description": "Counter\n===========\n\n.. image:: https://secure.travis-ci.org/KelSolaar/Counter.png?branch=master\n\nIntroduction\n------------\n\n**Counter** package defines the **counter.Counter** class similar to bags or multisets in other languages. This package is created from Raymond Hettinger recipe: http://code.activestate.com/recipes/576611/\n\nInstallation\n------------\n\nTo install **Foundations** from the `Python Package Index `_ you can issue this command in a shell::\n\n\tpip install Counter\n\nor this alternative command::\n\n\teasy_install Counter\n\nAlternatively, if you want to directly install from `Github `_ source repository::\n\n\tgit clone git://github.com/KelSolaar/Counter.git\n\tpython setup.py install\n\nUsage\n-----\n\nFor precise usage examples, please refer to the original recipe: http://code.activestate.com/recipes/576611/ and Python documentation: http://docs.python.org/library/collections.html#collections.Counter\n\n- **Tally occurrences of words in a list**::\n\n\n\t>>> cnt = Counter()\n\t>>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:\n\t... cnt[word] += 1\n\t>>> cnt\n\tCounter({'blue': 3, 'red': 2, 'green': 1})\n\n- **Find the ten most common words in Hamlet**::\n\n\n\t>>> import re\n\t>>> words = re.findall('\\w+', open('hamlet.txt').read().lower())\n\t>>> Counter(hamlet_words).most_common(10)\n\t[('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631),\n\t ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)]\n\n- **Multiset examples**::\n\n\n\t>>> c = Counter(a=3, b=1)\n\t>>> d = Counter(a=1, b=2)\n\t>>> c + d # add two counters together: c[x] + d[x]\n\tCounter({'a': 4, 'b': 3})\n\t>>> c - d # subtract (keeping only positive counts)\n\tCounter({'a': 2})\n\t>>> c & d # intersection: min(c[x], d[x])\n\tCounter({'a': 1, 'b': 1})\n\t>>> c | d # union: max(c[x], d[x])\n\tCounter({'a': 3, 'b': 2})\n\nAbout\n-----\n\n| **Counter** by Raymond Hettinger \u2013 2009\n| Copyright\u00a9 2009 - Raymond Hettinger\n| This software is released under terms of MIT license: http://opensource.org/licenses/mit-license.php\n| `thomas.mansencal@gmail.com `_\n| `http://www.thomasmansencal.com/ `_", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/KelSolaar/Counter", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "Counter", "package_url": "https://pypi.org/project/Counter/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Counter/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/KelSolaar/Counter" }, "release_url": "https://pypi.org/project/Counter/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "Counter package defines the \"counter.Counter\" class similar to bags or multisets in other languages.", "version": "1.0.0" }, "last_serial": 751034, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "1b49029693c28813ff276c2b16673f98", "sha256": "9e008590e360936a66c98e1a01e7a9a0ecf6af19cc588107121f5fb4613bb60c" }, "downloads": -1, "filename": "Counter-1.0.0.tar.gz", "has_sig": false, "md5_digest": "1b49029693c28813ff276c2b16673f98", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5239, "upload_time": "2012-09-19T20:01:00", "url": "https://files.pythonhosted.org/packages/7d/b0/23d19892f8d91ec9c5b8a2035659bce23587fed419d68fa3d70b6abf8bcd/Counter-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1b49029693c28813ff276c2b16673f98", "sha256": "9e008590e360936a66c98e1a01e7a9a0ecf6af19cc588107121f5fb4613bb60c" }, "downloads": -1, "filename": "Counter-1.0.0.tar.gz", "has_sig": false, "md5_digest": "1b49029693c28813ff276c2b16673f98", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5239, "upload_time": "2012-09-19T20:01:00", "url": "https://files.pythonhosted.org/packages/7d/b0/23d19892f8d91ec9c5b8a2035659bce23587fed419d68fa3d70b6abf8bcd/Counter-1.0.0.tar.gz" } ] }