TRIETOOL(1)

🌸 NAME 🌸

okay so bestie, this is TRIETOOL(1), straight out of the General Commands Manual, and it's about trietool β€” the trie manipulation tool. that's the whole name. short, sweet, powerful. πŸ‘‘


✨ SYNOPSIS ✨

trietool [ options ] trie command arg ...

πŸ’… DESCRIPTION πŸ’…

trietool is literally the command-line tool for manipulating double-array trie data, no cap. You can use it to query, add and remove words in a trie. it's giving data-structure royalty and honestly? we love to see it. πŸ’–

πŸ¦‹ The Trie πŸ¦‹

The trie argument specifies the name of the trie you wanna manipulate. A trie is stored in a file with a .tri extension. BUT β€” plot twist β€” to create a brand new trie, you need to prepare a file with an .abm extension first, describing the Unicode ranges of the alphabet set of the trie. The ABM defines a set of vectors that map Unicode characters into a continuous range of integers, and those mapped integers get used as the internal alphabet for the trie. This mapping is lowkey iconic because it improves space allocation within the trie data, regardless of how non-continuous the character set you're using is β€” since the mapped range is always continuous. slay. ✨

The ABM file is a plain text file, and each line lists a range of 32-bit Unicodes to be added to the alphabet set, in this format:

[0xSSSS,0xTTTT]

where 0xSSSS and 0xTTTT are hexadecimal values of the starting and ending character code for the range, respectively. periodt. πŸ’…

Example time πŸ“ β€” for a dictionary that contains only English words without any punctuations, you could prepare trie.abm like this:

[0x0041,0x005a]
[0x0061,0x007a]

The first line lists the ASCII codes for A-Z, and the second one's for a-z. cute!

⚠️ No more than 255 alphabets are allowed in a trie. that's the ceiling, bestie, we do not exceed it.

The .tri file you create will incorporate the ABM data. So the .abm file is not required after the first creation β€” it will just be ignored. bye felicia. πŸ™ˆ


πŸ‘‘ COMMANDS πŸ‘‘

Available commands are:

🌈 add word data ...

Add word to the trie, associated with integer data. You can give an arbitrary number of words-data pairs. Two arguments get read at a time β€” the first is treated as the word, and the second as the data. simple as that. ✨

🧚 add-list [ options ] list-file

Add words with their associated data, listed in list-file, to the trie. The list-file must be a text file listing one word per line. The associated data can be put after the word on the same line, separated with a tab (\t) character. And if the data field is omitted? A default value of -1 gets used instead. πŸ’–

Options available for this command:

  • -e, --encoding enc β€” specify the character encoding of the list-file contents, such as UTF-8. If you omit it, the current locale codeset is assumed.

πŸ’œ delete word ...

Delete word from the trie. You can give an arbitrary number of words to delete. gone, reduced to atoms. πŸ’€

πŸ¦‹ delete-list [ options ] list-file

Delete the words listed in list-file from the trie. The list-file must be a text file listing one word per line.

Options available for this command:

  • -e, --encoding enc β€” specify the character encoding of the list-file contents, such as UTF-8. If omitted, the current locale codeset is assumed.

⭐ query word

Search for word in the trie. If the word exists, its associated data is printed to standard output. Otherwise, an error message is printed to standard error, with nothing printed to standard output. vibe check: failed, but gracefully. 😭

🌸 list

List all the words in the trie to standard output. The output lists one word-data pair per line, separated with a tab (\t) character β€” the exact format appropriate for being a list-file for the add-list command. it's giving self-sustaining ecosystem, honestly obsessed. 🫢


πŸŽ€ OPTIONS πŸŽ€

This program follows the usual GNU command line syntax, with long options starting with two dashes (--). A summary of options is included below. πŸ’…

  • -p, --path dir β€” set trie directory to dir [default=.]
  • -h, --help β€” show summary of options.
  • -V, --version β€” show version of program.

🫢 AUTHOR 🫢

libdatrie was written by Theppitak Karoonboonyanan.

This manual page was written by Theppitak Karoonboonyanan <theppitak@gmail.com>. πŸ’Œ


and that's the whole page, bestie! it's TRIETOOL(1) from the General Commands Manual, December 2008 edition, and it lives in the libdatrie cinematic universe. go forth and manipulate your tries. πŸ’–βœ¨πŸ¦‹