View Source Sufx (Sufx v0.1.0)
A generic string fuzzy matching utility.
Please see examples in the readme file.
Summary
Functions
Compresses the given tree to a more memory and CPU efficient form.
Returns the original tree before compression.
Inserts a new phrase/value pair in an existing tree.
Creates an new, empty suffix tree.
Creates a new tree from tokens.
Matches all phrases in the tree with the given pattern and return all values associated with successfully matched phrases.
This function has the same behaviour as search/2
but the results are wrapped
in a tuple where the first element is the search result value and the second
element is the score.
Returns the given list of scored results sorted by descending score order.
Types
@type pattern() :: String.t()
@type phrase() :: String.t()
@type tokens() :: Enumerable.t({phrase(), term()})
Functions
Compresses the given tree to a more memory and CPU efficient form.
While memory footprint is optimized, and searches will be faster, a compressed tree does not support further insertion.
Returns the original tree before compression.
Inserts a new phrase/value pair in an existing tree.
This function does not support compressed trees.
@spec new() :: t()
Creates an new, empty suffix tree.
Creates a new tree from tokens.
Tokens are phrase/value pairs where the phrase is a string and the value any term.
Matches all phrases in the tree with the given pattern and return all values associated with successfully matched phrases.
Returns an empty list if the given pattern is an empty string.
@spec search_score(t(), pattern()) :: [{term(), non_neg_integer()}]
This function has the same behaviour as search/2
but the results are wrapped
in a tuple where the first element is the search result value and the second
element is the score.
Note that the results are not ordered by score, and multiple results can have the same score.
See sort_by_score/1
.
@spec sort_by_score([{term(), non_neg_integer()}]) :: [{term(), non_neg_integer()}]
Returns the given list of scored results sorted by descending score order.
Note that the order may slightly differ from an implementation with
Enum.sort_by/3
due to optimizations.
The function does nothing special and you are totally free to sort the results in any other way.