Skip to content

Latest commit

 

History

History
80 lines (65 loc) · 2.38 KB

README.md

File metadata and controls

80 lines (65 loc) · 2.38 KB

ExFuzzywuzzy

CI Module Version Hex Docs Total Download License Last Updated

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.

Installation

To install ExFuzzyWuzzy, just add an entry to your mix.exs:

def deps do
  [
    {:ex_fuzzywuzzy, "~> 0.3.0"}
  ]
end

Usage

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.

Simple ratio

iex> ExFuzzywuzzy.ratio("this is a test", "this is a test!")
96.55

Quick ratio

iex> ExFuzzywuzzy.quick_ratio("this is a test", "this is a test!")
100.0

Partial ratio

iex> ExFuzzywuzzy.partial_ratio("this is a test", "this is a test!")
100.0

Best Score ratio

iex> ExFuzzywuzzy.best_score_ratio("this is a test", "this is a test!")
{:quick, 100.0}

Contributing

Thank your for considering helping with this project. Please see CONTRIBUTING.md file for contributing to this project.

License

MIT License. Copyright (c) 2015-2024 Prima.it