#fuzzy-string #string-matching

fuzzywuzzy

A pure-Rust clone of the incredibly useful fuzzy string matching python package, FuzzyWuzzy

2 releases

Uses old Rust 2015

0.0.2 Sep 24, 2020
0.0.1 Sep 24, 2020

#1565 in Text processing

Download history 136/week @ 2024-07-20 130/week @ 2024-07-27 77/week @ 2024-08-03 93/week @ 2024-08-10 115/week @ 2024-08-17 72/week @ 2024-08-24 142/week @ 2024-08-31 126/week @ 2024-09-07 285/week @ 2024-09-14 483/week @ 2024-09-21 101/week @ 2024-09-28 181/week @ 2024-10-05 149/week @ 2024-10-12 150/week @ 2024-10-19 259/week @ 2024-10-26 334/week @ 2024-11-02

927 downloads per month
Used in rgwml

GPL-2.0-only

26KB
516 lines

fuzzywuzzy-rs

Fuzzy string matching like a boss. It uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package.

Note: This project was originally named fuzzyrusty. Someone else cloned and published it to crates.io https://crates.io/crates/fuzzyrusty. We do not control that crate. This is why we have changed the name.

Installation

fuzzywuzzy is currently available through GitHub or crates.io.

For the latest stable releas, add this to your Cargo.toml:

[dependencies]
fuzzywuzzy = "*"

For the bleeding edge, you can pull directly from master:

[dependencies]
fuzzywuzzy = { git = "https://github.com/logannc/fuzzywuzzy-rs", branch = "master" }

Documentation

Clone the repository and run $ cargo doc --open.

Usage

Simple Ratio

assert_eq!(fuzz::ratio("this is a test", "this is a test!"), 97);

Partial Ratio

assert_eq!(fuzz::partial_ratio("this is a test", "this is a test!"), 100);

Token Sort Ratio

assert_eq!(fuzz::ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear"), 91);  
assert_eq!(fuzz::token_sort_ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a bear", true, true), 100);

Token Set Ratio

assert_eq!(fuzz::ratio("fuzzy was a bear", "fuzzy fuzzy was a bear"), 84);  
assert_eq!(fuzz::token_set_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear", true, true), 100);

Process

assert_eq!(process::extract_one(  
  "cowboys",  
 &["Atlanta Falcons", "Dallas Cowboys", "New York Jets"],  
 &utils::full_process,  
 &fuzz::wratio,  
  0,  
), Some(("Dallas Cowboys".to_string(), 90)));

No runtime deps