tricli manages a trie data structure that can be globally accessed.
Project description
tricli
tricli is a python library that allows everybody to perform operations on my trie data structure. Note that the trie data structure is global and the same at any given moment for everyone.
tricli (given by the last three letters of its name) is meant to be used inside of the terminal as a command-line interface (CLI) and NOT inside of your code files.
Also note that the trie in tricli is case-sensitive, meaning that "Hello" and "hello" are considered to be two different words!
How to install
To install, go into your terminal and do :
pip install tricli
Make sure you are using Python 3 and pip3 if needed.
tricli operations
With tricli, you can add a word to trie, delete a word from the trie, clear the trie by removing all of its words, have the trie displayed to you, and get autocomplete suggestions for a given prefix string.
Avoid stopping a command while it is running (should only take a few seconds), because that may lead to your requested operation not being processed by the server.
With that in mind, let's take a closer look at each of these operations.
Add
Self-explanatory - the add operation adds a word to the trie.
Here's how you do that from your terminal :
tricli add WORD
where WORD is the word you want to add. If WORD is already inside the trie, nothing will happen.
Delete
The delete operation removes a word from the trie.
From terminal :
tricli delete WORD
where WORD is the word you want to delete. If WORD is not in the trie, then you will get a message saying that the operation failed. Note that if WORD is a prefix of other words in the trie, those other words will NOT get deleted.
Search
The search operation lets you know whether a word is inside of the trie or not.
Like such :
tricli search WORD
where WORD is the string you want to search for. If WORD is in the trie, you will get back True otherwise you will get False.
Clear
The clear operation removes all words inside of the trie. Just do (no parameters) :
tricli clear
Display
The display operation shows you the trie (more specifically, the words in a trie) in an indentational format to make it easy for you to understand.
As an example, say you have added the words "she", "sheet", "sheets", and "shot" (in that order) inside of your trie. Perform display by :
tricli display
and you can expect to see back :
she
sheet
sheets
shot
This indentation style becomes clear and intuitive with this example. Essentially the display method prints out the words in the trie based on their prefix, and indents on a word to show that this word can be made by adding characters at the end of above words.
Autocomplete
Lastly, the autocomplete function gives you the ability to type in a prefix string (regardless of whether its an actual word), and see if any words in the trie have that prefix.
Let's see this with the same example we used in display. First run :
tricli autocomplete sh
where "sh" can be replaced with any prefix string. Here we are looking for all of the words in the trie with the prefix "sh". You can then expect to get back :
['she', 'sheet', 'sheets', 'shot']
Final Remarks
That's it for the CLI. Hope you enjoy it. Feel free to email questions to anish.lakkapragada@gmail.com!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tricli-2.1.9.tar.gz
.
File metadata
- Download URL: tricli-2.1.9.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d2caab9f1cb84b1c118ab522e0b7c45c768e49d95f08f93d9251d076478ca35 |
|
MD5 | 06724eb1e4780b40a835d1332d4fcf11 |
|
BLAKE2b-256 | c5996b7bc6c73370c214166a639c22000ceed5e89f58d7b1c2bef9cbc246f567 |
File details
Details for the file tricli-2.1.9-py3-none-any.whl
.
File metadata
- Download URL: tricli-2.1.9-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36ef36008ba0927b8d6be328659089eefb7335d45f10ce3187a554f0e762fe18 |
|
MD5 | 1c54553d22c5a3a25ea00698140a2c74 |
|
BLAKE2b-256 | 8831d16364de82614368541cfd001b48473b7abdc858aac4c5a6e45c7d4e3489 |