...the library for finding string similarities 🔎
With this library you can easily find rate of similarity of two strings or array of strings. Under the hood LCS (length finding variant) algorithm is used with O(n * m) time complexity and O(min(n, m)) memory complexity.
```rust use similar_string::*;
// Compares similarity of two strings and returns similarity rating. // The rating is returned as a f64 value in range from 0.0 to 1.0. compare_similarity("age", "page"); // 0.75
let options = vec!["fill", "night", "ride"];
// Finds the best match amongst the options // and returns match with it's rating findbestsimilarity("fight", &options); // ("night", 0.8)
// Returns all the similarity ratings // of the provided options getsimilarityratings("fight", &options); // [0.4, 0.8, 0.2] ```
You can also use the lcs_length
that is used under the hood to compute length of longest common subsequence.
```rust use similarstring::lcslength;
// The longest common subsequence in this case is "one" lcs_length("longest", "stone"); // 3 ```
get_similarity_ratings
function that retrieves all the ratings of all optionsfind_best_similarity
function that finds string that matches the target one best