{ "info": { "author": "Aron Sajan Philip", "author_email": "arondeveloper@yahoo.com", "bugtrack_url": null, "classifiers": [], "description": "# Hash trie\r\n\r\n### Introduction\r\nHash trie is an enhanced Trie \r\ndata structure stores keyword indexes for faster keyword lookup. The storage is done in such a way that it does efficient memory usage and faster lookup.\r\n\r\n### Usage\r\n\r\n#### Importing and instantiating\r\n\r\n```\r\nfrom pyhtrie.htrie import Trie\r\ntrie = Trie()\r\n```\r\n\r\n#### Indexing\r\n\r\n> Syntax : trie.index_text(`data`, `keyword_to_index`)\r\n\r\n> `data` : Data can be any data to index\r\n> `keyword_to_index` : Keyword associated with the `data` indexed\r\n\r\n```\r\ntrie.index_text('car','car')\r\ntrie.index_text('cat','cat')\r\ntrie.index_text('cast','cast')\r\ntrie.index_text('Batman', 'batman')\r\ntrie.index_text('Bash', 'bash')\r\n```\r\n\r\n#### Prefix match\r\n\r\n> Syntax : trie.prefix_match(`prefix_text_to_search`)\r\n\r\nThe function returns all data matching the prefix text\r\n\r\n> `prefix_text_to_search` : Will be the prefix text on which the search will be performed. If there are no nodes matching the route of the prefix text then it will return an empty array\r\n\r\n\r\n```\r\ntrie.prefix_match('ca')\r\n```\r\n\r\n#### Pattern match\r\n\r\n> Syntax : trie.pattern_match(`pattern_text_to_search`)\r\n\r\nThis function returns all data associated with the text pattern. When compared to the prefix_match function, this function need not necessarily require the `pattern_text_to_search` to match with the prefix of the keyword to be searched for. The `pattern_text_to_search` can appear anywhere within the keyword\r\n\r\n> `pattern_text_to_search` : Is the text pattern to be searched. \r\n\r\n```\r\ntrie.pattern_match('at')\r\n```\r\n\r\n### Storage details\r\n\r\nThe keywords to be indexed are stored in a Trie data structure as can be seen in the image below. However for faster indexing of pattern match within keywords, each node in the trie is added to the hash-map with the letter corresponding to the node being the key.\r\n\r\n![Trie](https://raw.githubusercontent.com/aronsajan/pyhtrie/master/trie_img.png)\r\n\r\nSo if you need to search for any words beginning with 'ca', then `prefix_match('ca')` will return `[cat, car, cast]` as in a regular trie. However, if you want to search for any words with 'at' in them, you can use the function `pattern_match('as')` that will return `[cat, batman]`. The prefix match is done with the help of the hash-map. When a prefix match of `'at'` is done, the hash-map is checked for the letter `'a'` in `'at'`. This returns a list of three a nodes `[a,a,a]` each pointing to a correspinding `'a'` node in the tries as shown in the figure above. Then each of them are traversed to see which of them have the next node as `'t'` of `'at'`. The result will be the `'t'` of `'cat'` and the `'t'` preceding `'m'` in `'batman'`. Then the algorithm performs a collection operation from each of these 't's returned to retrieve keywords stored under those t's. The result, as can be inferred from the figure above, will be `[cat, batman]`\r\n\r\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/aronsajan/pyhtrie/tree/master", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pyhtrie", "package_url": "https://pypi.org/project/pyhtrie/", "platform": "", "project_url": "https://pypi.org/project/pyhtrie/", "project_urls": { "Homepage": "https://github.com/aronsajan/pyhtrie/tree/master" }, "release_url": "https://pypi.org/project/pyhtrie/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "Hashed Trie data structure for faster memory efficient and fast keyword indexing and lookup", "version": "1.0.0" }, "last_serial": 4833392, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "1ac115ceec062eace6e8e8e28934047b", "sha256": "490b0b634d978b408e088db90af23cda8af3af03aae8d84eb4060791f8e4f248" }, "downloads": -1, "filename": "pyhtrie-1.0.0-py2-none-any.whl", "has_sig": false, "md5_digest": "1ac115ceec062eace6e8e8e28934047b", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 4333, "upload_time": "2019-02-18T05:16:23", "url": "https://files.pythonhosted.org/packages/cf/d0/1b085697e7f5bbc81908b2a9ed6326f06ab5f1c0391f9742dcc0aeba7735/pyhtrie-1.0.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3e4ffa23fd25217b211b19323c3f1af7", "sha256": "b848df369f3a8be380b478ccd9c535bb22ada67a084ce6b704b3cd45fbc152a9" }, "downloads": -1, "filename": "pyhtrie-1.0.0.tar.gz", "has_sig": false, "md5_digest": "3e4ffa23fd25217b211b19323c3f1af7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2800, "upload_time": "2019-02-18T05:16:25", "url": "https://files.pythonhosted.org/packages/05/d7/3343fd865ca866b9fc5195c84bbd92e41070a2af4dad5efea392a091896e/pyhtrie-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1ac115ceec062eace6e8e8e28934047b", "sha256": "490b0b634d978b408e088db90af23cda8af3af03aae8d84eb4060791f8e4f248" }, "downloads": -1, "filename": "pyhtrie-1.0.0-py2-none-any.whl", "has_sig": false, "md5_digest": "1ac115ceec062eace6e8e8e28934047b", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 4333, "upload_time": "2019-02-18T05:16:23", "url": "https://files.pythonhosted.org/packages/cf/d0/1b085697e7f5bbc81908b2a9ed6326f06ab5f1c0391f9742dcc0aeba7735/pyhtrie-1.0.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3e4ffa23fd25217b211b19323c3f1af7", "sha256": "b848df369f3a8be380b478ccd9c535bb22ada67a084ce6b704b3cd45fbc152a9" }, "downloads": -1, "filename": "pyhtrie-1.0.0.tar.gz", "has_sig": false, "md5_digest": "3e4ffa23fd25217b211b19323c3f1af7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2800, "upload_time": "2019-02-18T05:16:25", "url": "https://files.pythonhosted.org/packages/05/d7/3343fd865ca866b9fc5195c84bbd92e41070a2af4dad5efea392a091896e/pyhtrie-1.0.0.tar.gz" } ] }