Convert list of text separated by line into a tree.
Each repetition in slice of text are detected and branched into list of branches or leaf to make the list optimized for storage or research.
The program was first designed to make big optimized regex of keywords for TextMate grammar (used in the nushell vscode extension)
list-to-tree <--format <Format>> [--input <path>] [--output <path>] [--pretty]
format
: Format of the output. Possible value :regex
: Output the tree into a regexrust
: Output the tree into rust ast
input
: Path to the file containing the list of words. Default to stdinoutput
: Path to the file where the output will be written. Default to stdoutpretty
: Pretty print the output (forrust
format). Default to false
Let say we have this list in input :
all
alias
abra
abro
The output list-to-tree --format rust --pretty
will be
Branch(
"a",
[
Branch(
"br",
[
Leaf(
"a",
),
Leaf(
"o",
),
],
"l",
[
Leaf(
"ias",
),
Leaf(
"l",
),
],
),
],
)
And here is the result for list-to-tree --format regex
a(?:br(?:a|o)|l(?:ias|l))
Since it's using rust cargo, all you have to do is cargo b --release
to build the program.