Alcs
All Longest Common Substrings and Fuzzy String Search for Rust
Link to crates.io
Implementation of An all-substrings common subsequence algorithm
Given two strings s1 and s2, it is possible construct, in O(|s1|*|s2|) time and O(|s1|+|s2|) space, a structure that can be queried to find the length of all Longest Common Subsequences between s1 and all possible substrings of s2, each query requiring constant time.
Some accessor functions are provided to retrieve the matrices and the vectors defined in the paper
All LCS
extern crate alcs;
use Alcs;
Output:
LCS between "word" and "h" has length 0
LCS between "word" and "he" has length 0
LCS between "word" and "hel" has length 0
...
LCS between "word" and " world" has length 4
LCS between "word" and "w" has length 1
LCS between "word" and "wo" has length 2
LCS between "word" and "wor" has length 3
...
LCS between "word" and "d" has length 1
Fuzzy substring
Also, it is defined a trait that allows to fuzzy search a string:
extern crate alcs;
use FuzzyStrstr;
Output:
"he.llo.wor.ld.!" contains "world" ("wor.ld") with score 0.8333333
"he.llo.word" contains "world" ("word") with score 0.8
"hello world" contains "word" ("world") with score 0.8
"hello world" does not contain "banana"