{ "info": { "author": "Bram Gerritsen", "author_email": "b.gerritsen@uu.nl", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Indexing", "Topic :: Text Processing :: Linguistic" ], "description": "vtrie\n=====\n\nTrie structure supporting approximate string matching (substitutions only) for\nPython (2.x and 3.x).\n\n.. NOTE::\n\n Only ascii strings are supported. Hence, Python 3 users should use\n 'b' prefix to insert strings into the trie.\n\nInstallation\n============\n\n::\n\n pip install vtrie\n\nFeatures\n========\n\n* It is similar to a dict() in general usage, and supports much of the dict()\n interface:\n\n * __len__(): number of items in the trie\n * __contains()__\n * __getitem()__\n * __setitem()__\n * __delitem()__\n * __sizeof()__: size of the trie in bytes\n * __repr()__: dict-like output, showing contents of the trie\n * has_key()\n * setdefault()\n * get()\n * pop()\n * popitem()\n * keys()\n * values()\n * items()\n * iterkeys()\n * itervalues()\n * iteritems()\n\n* Trie-specific methods:\n\n * num_nodes(): number of nodes\n * longest_prefix(k): find longest key matching the beginning of k,\n returning (key, value) pair as a 2-tuple. None is returned if no match.\n * suffixes(k): iterate over all (suffix, value) pairs as 2-tuples, that\n have k as a prefix.\n * neighbors(key = k, maxhd = n): iterate over all\n (Hamming distance, key, value) triples, as 3 tuples, where key and k\n differ by at least 1, but maximally n characters.\n Note, one can only search for neighbors of *existing* keys.\n * pairs(keylen = l, maxhd = n): iterate over *ALL*\n (Hamming distance, key1, value1, key2, value2) 5-tuples where key1 and key2\n differ by at least 1, but maximally n characters. Note, pairs() returns a\n dirty iterator, meaning that nodes in the trie are modified while the\n iterator is running. An exception will be thrown when iterating with more\n than one dirty iterator.\n\n* Pickling\n\nUsage\n=====\n\nCreate a trie::\n\n >>> from vtrie import Trie\n >>> t = Trie()\n\nAdd strings to the trie. Currently, only ascii strings are supported::\n\n >>> t[b\"Hello\"] = 123\n >>> t[b\"World\"] = {\"my\": \"dict\"}\n >>> t[b\"foo\"] = None\n\nCheck if \"Hello\" is in the trie::\n\n >>> b\"Hello\" in t\n True\n\nShow all inserted strings sharing the same prefix::\n\n >>> t[b\"foo\"] = 0\n >>> t[b\"foobar\"] = 1\n >>> t[b\"fooo\"] = 2\n >>> t[b\"hello\"] = 3\n >>> list(t.suffixes(b\"fo\"))\n [('o', 0), ('obar', 1), ('oo', 2)]\n\nSearch for keys that differ by less than a given number of substitutions from\nthe provided key. The results are tuples with first the Hamming distance\nbetween the given key and the found key, then the found key and its value::\n\n >>> t[b\"hello world\"] = 0\n >>> t[b\"*ello world\"] = \"a\"\n >>> t[b\"*ell* world\"] = \"b\"\n >>> t[b\"*ell* w*rld\"] = \"c\"\n >>> t[b\"hell* w*rl*\"] = \"d\"\n >>> list(t.neighbors(b\"hello world\", maxhd = 1))\n [(1, '*ello world', 'a')]\n >>> list(t.neighbors(b\"hello world\", maxhd = 2))\n [(1, '*ello world', 'a'), (2, '*ell* world', 'b')]\n >>> print(\"\\n\".join(map(str,list(t.neighbors(b\"hello world\", 3)))))\n (3, 'hell* w*rl*', 'd')\n (1, '*ello world', 'a')\n (2, '*ell* world', 'b')\n (3, '*ell* w*rld', 'c')\n\nSearch for all keys of a certain length that are within a certain Hamming of\neach other. The results are tuples with first the Hamming distance between the\nfound keys, then the first key and its value, and then the second key and\nits value::\n\n >>> print(\"\\n\".join(map(str,list(t.pairs(keylen = 11, maxhd = 2)))))\n (1, 'hello world', 0, '*ello world', 'a')\n (2, 'hello world', 0, '*ell* world', 'b')\n (2, 'hell* w*rl*', 'd', '*ell* w*rld', 'c')\n (1, '*ello world', 'a', '*ell* world', 'b')\n (2, '*ello world', 'a', '*ell* w*rld', 'c')\n (1, '*ell* world', 'b', '*ell* w*rld', 'c')", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": "trie tree datastructure dictionary Hamming distance", "license": "GPLv3", "maintainer": null, "maintainer_email": null, "name": "vtrie", "package_url": "https://pypi.org/project/vtrie/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/vtrie/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/vtrie/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "A trie structure supporting fuzzy string searches.", "version": "0.0.2" }, "last_serial": 2305001, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "816dddfeddae9c30f54d3e2e3dfe1bb6", "sha256": "2bc5864c36739e95f6eaa5674a09a0de4936a356fec1c50c60a1881e9ed212cd" }, "downloads": -1, "filename": "vtrie-0.0.1.tar.gz", "has_sig": false, "md5_digest": "816dddfeddae9c30f54d3e2e3dfe1bb6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32553, "upload_time": "2016-02-08T23:46:20", "url": "https://files.pythonhosted.org/packages/91/e5/ced292169b62e06c0eb7a8e5123d431b0ee071469ca7264aed38be374431/vtrie-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "8b6ac4035d4434f0f5725bf0fd24ac2c", "sha256": "f0346f597d042763339111029c30a390bc5a6f4d451ee019ae98386d2ae8717f" }, "downloads": -1, "filename": "vtrie-0.0.2.tar.gz", "has_sig": false, "md5_digest": "8b6ac4035d4434f0f5725bf0fd24ac2c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34290, "upload_time": "2016-08-25T22:53:41", "url": "https://files.pythonhosted.org/packages/fa/31/3910e8f74dea24aff0df840f3d4e1aee96eb186a12ae377a089be07fede3/vtrie-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8b6ac4035d4434f0f5725bf0fd24ac2c", "sha256": "f0346f597d042763339111029c30a390bc5a6f4d451ee019ae98386d2ae8717f" }, "downloads": -1, "filename": "vtrie-0.0.2.tar.gz", "has_sig": false, "md5_digest": "8b6ac4035d4434f0f5725bf0fd24ac2c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34290, "upload_time": "2016-08-25T22:53:41", "url": "https://files.pythonhosted.org/packages/fa/31/3910e8f74dea24aff0df840f3d4e1aee96eb186a12ae377a089be07fede3/vtrie-0.0.2.tar.gz" } ] }