astrie


Nameastrie JSON
Version 1.2 PyPI version JSON
download
home_pagehttps://github.com/ashishyadav2/astrie
SummaryA simple trie data structure implementation
upload_time2023-08-27 14:59:17
maintainer
docs_urlNone
authorAshish Yadav
requires_python
licenseMIT
keywords trie astrie data structures trie data structure
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ### Getting Started

To get started with using the `astrie` package, follow these steps:

1. **Installation**

    Install the package using pip:
    ```bash
    pip install astrie
    ```

2. **Importing**

    Import the `AsTrie` class from the `astrie` module:
    ```python
    from astrie import AsTrie
    ```

3. **Object Initialization**

    Initialize an instance of the `AsTrie` class:
    ```python
    trie = AsTrie()
    ```

### Methods

#### Adding Words

To add words to the trie, you can use the following methods:

- To add a single word:
    ```python
    trie.add("Python")
    ```

- To add a list of words at once:
    ```python
    word_list = ["pineapple", "butterfly", "adventure", "rainbow", "whisper",
        "enchantment", "tranquility", "galaxy", "serendipity", "blossom",
        "chocolate", "meadow", "firefly", "symphony", "serenade",
        "moonlight", "horizon", "oasis", "velvet", "reflection",
        "sunrise", "wonder", "starlight", "cascade", "mystic",
        "melody", "twilight", "radiant", "journey", "destiny",
        "harmony", "peaceful", "embrace", "shimmer", "gentle",
        "serene", "dreamer", "captivate", "inspire", "tranquility",
        "cherish", "ethereal", "wanderlust", "cherished", "radiant",
        "adventure", "captivate", "radiant", "enjoy", "serenity","Python","Hello","World"]
        
    trie.add_many(word_list)
    ```

#### Removing Words

To remove words from the trie, you can use these methods:

- To remove a single word:
    ```python
    trie.remove("Python")
    ```

- To remove a list of words:
    ```python
    trie.remove_many(["Hello", "World"])
    ```

- To empty the trie:
    ```python
    trie.clear()
    ```

#### Checking and Counting

You can perform various checks and obtain counts using these methods:

- To check if a word exists in the trie:
    ```python
    exists = trie.has("horizon")
    print(exists)
    
    >>> True
    ```

- To check if there are words that start with a given prefix:
    ```python
    starts_with = trie.starts_with("ad")
    print(starts_with)
    
    >>> True
    ```

- To get the count of words that start with a prefix:
    ```python
    starts_with_count = trie.starts_with_count("ad")
    print(starts_with_count)
    
    >>> 2
    ```

- To get the count of words equal to a given word:
    ```python
    count_equals = trie.count_equals("adventure")
    print(count_equals)
    
    >>> 2
    ```

- To get the count of unique words in the trie:
    ```python
    unique_count = trie.unique_count()
    print(unique_count)
    
    >>> 48
    ```

#### Retrieving Words

You can retrieve words using these methods:

- To get a generator object for all words in the trie:
    ```python
    all_words_generator = trie.all_words()
    for word in all_words_generator:
        print(word)
    
    >>> 
    pineapple
    butterfly
    adventure
    ...
    World
    ```

- To get a generator object for words that start with a prefix:
    ```python
    starts_with_generator = trie.words_starts_with("m")
    for word in starts_with_generator :
        print(word)
    >>>
    meadow
    melody
    moonlight
    mystic
    ```

Remember that for generator objects, you need to iterate over them to access the actual words they yield.
###### Note: This trie only works on alphabetical characters. If you want to use intergers typecast them into string before adding them to the trie.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ashishyadav2/astrie",
    "name": "astrie",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "trie,astrie,data structures,trie data structure",
    "author": "Ashish Yadav",
    "author_email": "unixm98@gmail.com",
    "download_url": "",
    "platform": null,
    "description": "### Getting Started\r\n\r\nTo get started with using the `astrie` package, follow these steps:\r\n\r\n1. **Installation**\r\n\r\n    Install the package using pip:\r\n    ```bash\r\n    pip install astrie\r\n    ```\r\n\r\n2. **Importing**\r\n\r\n    Import the `AsTrie` class from the `astrie` module:\r\n    ```python\r\n    from astrie import AsTrie\r\n    ```\r\n\r\n3. **Object Initialization**\r\n\r\n    Initialize an instance of the `AsTrie` class:\r\n    ```python\r\n    trie = AsTrie()\r\n    ```\r\n\r\n### Methods\r\n\r\n#### Adding Words\r\n\r\nTo add words to the trie, you can use the following methods:\r\n\r\n- To add a single word:\r\n    ```python\r\n    trie.add(\"Python\")\r\n    ```\r\n\r\n- To add a list of words at once:\r\n    ```python\r\n    word_list = [\"pineapple\", \"butterfly\", \"adventure\", \"rainbow\", \"whisper\",\r\n        \"enchantment\", \"tranquility\", \"galaxy\", \"serendipity\", \"blossom\",\r\n        \"chocolate\", \"meadow\", \"firefly\", \"symphony\", \"serenade\",\r\n        \"moonlight\", \"horizon\", \"oasis\", \"velvet\", \"reflection\",\r\n        \"sunrise\", \"wonder\", \"starlight\", \"cascade\", \"mystic\",\r\n        \"melody\", \"twilight\", \"radiant\", \"journey\", \"destiny\",\r\n        \"harmony\", \"peaceful\", \"embrace\", \"shimmer\", \"gentle\",\r\n        \"serene\", \"dreamer\", \"captivate\", \"inspire\", \"tranquility\",\r\n        \"cherish\", \"ethereal\", \"wanderlust\", \"cherished\", \"radiant\",\r\n        \"adventure\", \"captivate\", \"radiant\", \"enjoy\", \"serenity\",\"Python\",\"Hello\",\"World\"]\r\n        \r\n    trie.add_many(word_list)\r\n    ```\r\n\r\n#### Removing Words\r\n\r\nTo remove words from the trie, you can use these methods:\r\n\r\n- To remove a single word:\r\n    ```python\r\n    trie.remove(\"Python\")\r\n    ```\r\n\r\n- To remove a list of words:\r\n    ```python\r\n    trie.remove_many([\"Hello\", \"World\"])\r\n    ```\r\n\r\n- To empty the trie:\r\n    ```python\r\n    trie.clear()\r\n    ```\r\n\r\n#### Checking and Counting\r\n\r\nYou can perform various checks and obtain counts using these methods:\r\n\r\n- To check if a word exists in the trie:\r\n    ```python\r\n    exists = trie.has(\"horizon\")\r\n    print(exists)\r\n    \r\n    >>> True\r\n    ```\r\n\r\n- To check if there are words that start with a given prefix:\r\n    ```python\r\n    starts_with = trie.starts_with(\"ad\")\r\n    print(starts_with)\r\n    \r\n    >>> True\r\n    ```\r\n\r\n- To get the count of words that start with a prefix:\r\n    ```python\r\n    starts_with_count = trie.starts_with_count(\"ad\")\r\n    print(starts_with_count)\r\n    \r\n    >>> 2\r\n    ```\r\n\r\n- To get the count of words equal to a given word:\r\n    ```python\r\n    count_equals = trie.count_equals(\"adventure\")\r\n    print(count_equals)\r\n    \r\n    >>> 2\r\n    ```\r\n\r\n- To get the count of unique words in the trie:\r\n    ```python\r\n    unique_count = trie.unique_count()\r\n    print(unique_count)\r\n    \r\n    >>> 48\r\n    ```\r\n\r\n#### Retrieving Words\r\n\r\nYou can retrieve words using these methods:\r\n\r\n- To get a generator object for all words in the trie:\r\n    ```python\r\n    all_words_generator = trie.all_words()\r\n    for word in all_words_generator:\r\n        print(word)\r\n    \r\n    >>> \r\n    pineapple\r\n    butterfly\r\n    adventure\r\n    ...\r\n    World\r\n    ```\r\n\r\n- To get a generator object for words that start with a prefix:\r\n    ```python\r\n    starts_with_generator = trie.words_starts_with(\"m\")\r\n    for word in starts_with_generator :\r\n        print(word)\r\n    >>>\r\n    meadow\r\n    melody\r\n    moonlight\r\n    mystic\r\n    ```\r\n\r\nRemember that for generator objects, you need to iterate over them to access the actual words they yield.\r\n###### Note: This trie only works on alphabetical characters. If you want to use intergers typecast them into string before adding them to the trie.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple trie data structure implementation",
    "version": "1.2",
    "project_urls": {
        "Homepage": "https://github.com/ashishyadav2/astrie"
    },
    "split_keywords": [
        "trie",
        "astrie",
        "data structures",
        "trie data structure"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f2ab1d2895c9d81d1ae1dac1decbce347eb993e8cea5bfeb0aed3a6dc2291a5a",
                "md5": "58351d720f7d05fa6ec8767fbf511fde",
                "sha256": "e432090c3487213dc28ac756d055a589ea26dc5792b4dbea1de0603e9aa6a6e4"
            },
            "downloads": -1,
            "filename": "astrie-1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "58351d720f7d05fa6ec8767fbf511fde",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3138,
            "upload_time": "2023-08-27T14:59:17",
            "upload_time_iso_8601": "2023-08-27T14:59:17.015265Z",
            "url": "https://files.pythonhosted.org/packages/f2/ab/1d2895c9d81d1ae1dac1decbce347eb993e8cea5bfeb0aed3a6dc2291a5a/astrie-1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-27 14:59:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ashishyadav2",
    "github_project": "astrie",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "astrie"
}
        
Elapsed time: 0.10638s