RapidFuzz
Loading...
Searching...
No Matches
Functions
Fuzz

Functions

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::ratio (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
 calculates a simple ratio between two strings More...
 
template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::partial_ratio (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
 calculates the fuzz::ratio of the optimal string alignment More...
 
template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::token_sort_ratio (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
 Sorts the words in the strings and calculates the fuzz::ratio between them. More...
 
template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::partial_token_sort_ratio (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
 Sorts the words in the strings and calculates the fuzz::partial_ratio between them. More...
 
template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::token_set_ratio (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
 Compares the words in the strings based on unique and common words between them using fuzz::ratio. More...
 
template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::partial_token_set_ratio (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
 Compares the words in the strings based on unique and common words between them using fuzz::partial_ratio. More...
 
template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::token_ratio (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
 Helper method that returns the maximum of fuzz::token_set_ratio and fuzz::token_sort_ratio (faster than manually executing the two functions) More...
 
template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::partial_token_ratio (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
 Helper method that returns the maximum of fuzz::partial_token_set_ratio and fuzz::partial_token_sort_ratio (faster than manually executing the two functions) More...
 
template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::WRatio (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
 Calculates a weighted ratio based on the other ratio algorithms. More...
 
template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::QRatio (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
 Calculates a quick ratio between two strings using fuzz.ratio. More...
 

Detailed Description

A collection of string matching algorithms from FuzzyWuzzy

Function Documentation

◆ partial_ratio()

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::partial_ratio ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
double  score_cutoff = 0 
)

#include <rapidfuzz/fuzz.hpp>

calculates the fuzz::ratio of the optimal string alignment

test [hyrro_2004] [wagner_fischer_1974]

// score is 100
double score = partial_ratio("this is a test", "this is a test!")
double partial_ratio(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
calculates the fuzz::ratio of the optimal string alignment
Template Parameters
Sentence1This is a string that can be converted to basic_string_view<char_type>
Sentence2This is a string that can be converted to basic_string_view<char_type>
Parameters
s1string to compare with s2 (for type info check Template parameters above)
s2string to compare with s1 (for type info check Template parameters above)
score_cutoffOptional argument for a score threshold between 0% and 100%. Matches with a lower score than this number will not be returned. Defaults to 0.
Returns
returns the ratio between s1 and s2 or 0 when ratio < score_cutoff

◆ partial_token_ratio()

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::partial_token_ratio ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
double  score_cutoff = 0 
)

#include <rapidfuzz/fuzz.hpp>

Helper method that returns the maximum of fuzz::partial_token_set_ratio and fuzz::partial_token_sort_ratio (faster than manually executing the two functions)

Template Parameters
Sentence1This is a string that can be converted to basic_string_view<char_type>
Sentence2This is a string that can be converted to basic_string_view<char_type>
Parameters
s1string to compare with s2 (for type info check Template parameters above)
s2string to compare with s1 (for type info check Template parameters above)
score_cutoffOptional argument for a score threshold between 0% and 100%. Matches with a lower score than this number will not be returned. Defaults to 0.
Returns
returns the ratio between s1 and s2 or 0 when ratio < score_cutoff

◆ partial_token_set_ratio()

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::partial_token_set_ratio ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
double  score_cutoff = 0 
)

#include <rapidfuzz/fuzz.hpp>

Compares the words in the strings based on unique and common words between them using fuzz::partial_ratio.

Template Parameters
Sentence1This is a string that can be converted to basic_string_view<char_type>
Sentence2This is a string that can be converted to basic_string_view<char_type>
Parameters
s1string to compare with s2 (for type info check Template parameters above)
s2string to compare with s1 (for type info check Template parameters above)
score_cutoffOptional argument for a score threshold between 0% and 100%. Matches with a lower score than this number will not be returned. Defaults to 0.
Returns
returns the ratio between s1 and s2 or 0 when ratio < score_cutoff

◆ partial_token_sort_ratio()

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::partial_token_sort_ratio ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
double  score_cutoff = 0 
)

#include <rapidfuzz/fuzz.hpp>

Sorts the words in the strings and calculates the fuzz::partial_ratio between them.

Template Parameters
Sentence1This is a string that can be converted to basic_string_view<char_type>
Sentence2This is a string that can be converted to basic_string_view<char_type>
Parameters
s1string to compare with s2 (for type info check Template parameters above)
s2string to compare with s1 (for type info check Template parameters above)
score_cutoffOptional argument for a score threshold between 0% and 100%. Matches with a lower score than this number will not be returned. Defaults to 0.
Returns
returns the ratio between s1 and s2 or 0 when ratio < score_cutoff

◆ QRatio()

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::QRatio ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
double  score_cutoff = 0 
)

#include <rapidfuzz/fuzz.hpp>

Calculates a quick ratio between two strings using fuzz.ratio.

Template Parameters
Sentence1This is a string that can be converted to basic_string_view<char_type>
Sentence2This is a string that can be converted to basic_string_view<char_type>
Parameters
s1string to compare with s2 (for type info check Template parameters above)
s2string to compare with s1 (for type info check Template parameters above)
score_cutoffOptional argument for a score threshold between 0% and 100%. Matches with a lower score than this number will not be returned. Defaults to 0.
Returns
returns the ratio between s1 and s2 or 0 when ratio < score_cutoff

◆ ratio()

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::ratio ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
double  score_cutoff = 0 
)

#include <rapidfuzz/fuzz.hpp>

calculates a simple ratio between two strings

// score is 96.55
double score = ratio("this is a test", "this is a test!")
double ratio(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
calculates a simple ratio between two strings
Template Parameters
Sentence1This is a string that can be converted to basic_string_view<char_type>
Sentence2This is a string that can be converted to basic_string_view<char_type>
Parameters
s1string to compare with s2 (for type info check Template parameters above)
s2string to compare with s1 (for type info check Template parameters above)
score_cutoffOptional argument for a score threshold between 0% and 100%. Matches with a lower score than this number will not be returned. Defaults to 0.
Returns
returns the ratio between s1 and s2 or 0 when ratio < score_cutoff

◆ token_ratio()

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::token_ratio ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
double  score_cutoff = 0 
)

#include <rapidfuzz/fuzz.hpp>

Helper method that returns the maximum of fuzz::token_set_ratio and fuzz::token_sort_ratio (faster than manually executing the two functions)

Template Parameters
Sentence1This is a string that can be converted to basic_string_view<char_type>
Sentence2This is a string that can be converted to basic_string_view<char_type>
Parameters
s1string to compare with s2 (for type info check Template parameters above)
s2string to compare with s1 (for type info check Template parameters above)
score_cutoffOptional argument for a score threshold between 0% and 100%. Matches with a lower score than this number will not be returned. Defaults to 0.
Returns
returns the ratio between s1 and s2 or 0 when ratio < score_cutoff

◆ token_set_ratio()

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::token_set_ratio ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
double  score_cutoff = 0 
)

#include <rapidfuzz/fuzz.hpp>

Compares the words in the strings based on unique and common words between them using fuzz::ratio.

// score1 is 83.87
double score1 = token_sort_ratio("fuzzy was a bear", "fuzzy fuzzy was a
bear")
// score2 is 100
double score2 = token_set_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
double token_sort_ratio(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
Sorts the words in the strings and calculates the fuzz::ratio between them.
double token_set_ratio(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, double score_cutoff=0)
Compares the words in the strings based on unique and common words between them using fuzz::ratio.
Template Parameters
Sentence1This is a string that can be converted to basic_string_view<char_type>
Sentence2This is a string that can be converted to basic_string_view<char_type>
Parameters
s1string to compare with s2 (for type info check Template parameters above)
s2string to compare with s1 (for type info check Template parameters above)
score_cutoffOptional argument for a score threshold between 0% and 100%. Matches with a lower score than this number will not be returned. Defaults to 0.
Returns
returns the ratio between s1 and s2 or 0 when ratio < score_cutoff

◆ token_sort_ratio()

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::token_sort_ratio ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
double  score_cutoff = 0 
)

#include <rapidfuzz/fuzz.hpp>

Sorts the words in the strings and calculates the fuzz::ratio between them.

// score is 100
double score = token_sort_ratio("fuzzy wuzzy was a bear", "wuzzy fuzzy was a
bear")
Template Parameters
Sentence1This is a string that can be converted to basic_string_view<char_type>
Sentence2This is a string that can be converted to basic_string_view<char_type>
Parameters
s1string to compare with s2 (for type info check Template parameters above)
s2string to compare with s1 (for type info check Template parameters above)
score_cutoffOptional argument for a score threshold between 0% and 100%. Matches with a lower score than this number will not be returned. Defaults to 0.
Returns
returns the ratio between s1 and s2 or 0 when ratio < score_cutoff

◆ WRatio()

template<typename InputIt1 , typename InputIt2 >
double rapidfuzz::fuzz::WRatio ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
double  score_cutoff = 0 
)

#include <rapidfuzz/fuzz.hpp>

Calculates a weighted ratio based on the other ratio algorithms.

Template Parameters
Sentence1This is a string that can be converted to basic_string_view<char_type>
Sentence2This is a string that can be converted to basic_string_view<char_type>
Parameters
s1string to compare with s2 (for type info check Template parameters above)
s2string to compare with s1 (for type info check Template parameters above)
score_cutoffOptional argument for a score threshold between 0% and 100%. Matches with a lower score than this number will not be returned. Defaults to 0.
Returns
returns the ratio between s1 and s2 or 0 when ratio < score_cutoff