ExFuzzyWuzzy is a fuzzy string matching library that provides many ways of calculating a matching ratio between two strings, starting from a similarity function which can be based on Levenshtein or Jaro-Winkler or a custom one.
The library is an Elixir port of SeatGeek's fuzzywuzzy.
To install ExFuzzyWuzzy, just add an entry to your mix.exs
:
def deps do
[
{:ex_fuzzywuzzy, "~> 0.2.0"}
]
end
Choose the ratio function which fits best your needs among the available, providing the two strings to be matched and - if needed - overwriting options over the configured ones.
Available methods are:
- Simple ratio
- Quick ratio
- Partial ratio
- Token sort ratio
- Partial token sort ratio
- Token set ratio
- Partial token set ratio
- Best score ratio
Available options are:
- Similarity function (Levenshtein and Jaro-Winkler provided in library)
- Case sensitiveness of match
- Decimal precision of output score
Here are some examples.
iex> ExFuzzywuzzy.ratio("this is a test", "this is a test!")
96.55
iex> ExFuzzywuzzy.quick_ratio("this is a test", "this is a test!")
100.0
iex> ExFuzzywuzzy.partial_ratio("this is a test", "this is a test!")
100.0
iex> ExFuzzywuzzy.best_score_ratio("this is a test", "this is a test!")
{:quick, 100.0}
Thank your for considering helping with this project. Please see
CONTRIBUTING.md
file for contributing to this project.
MIT License. Copyright (c) 2015-2021 Prima.it