rapidfuzz(3)

πŸ“¦
version 3.3.3 Β· 2 versions
, in fedora 44

πŸ’– rapidfuzz(3) πŸ’–

okay bestie, welcome to rapidfuzz(3) β€” this page comes straight out of the Library Functions Manual, section 3, and it's giving "C++ string matching but make it fast" energy. We're doing this in parts, this is part 1, so hydrate and stay with me. πŸŽ€βœ¨


πŸ‘‘ NAME πŸ‘‘

rapidfuzz β€” rapidfuzz.

that's it. that's the name. she's self-titled. main character energy, no notes. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

🌸 Functions 🌸

okay so here's the whole squad of functions. they're all templates, they all take two sentences and a score_cutoff that defaults to 0, and they all hand you back a double. iconic consistency, fr fr. 🌈

  • rapidfuzz::fuzz::ratio β€” calculates a simple ratio between two strings. the baseline, the blueprint, the moment. 🫢
template<typename Sentence1, typename Sentence2> double
    rapidfuzz::fuzz::ratio (const Sentence1 &s1, const Sentence2 &s2,
    double score_cutoff=0)
  • rapidfuzz::fuzz::partial_ratio β€” calculates the fuzz::ratio of the optimal string alignment. she's looking for the best fit, not the whole thing. lowkey obsessed with her. ✨
template<typename Sentence1, typename Sentence2> double
    rapidfuzz::fuzz::partial_ratio (const Sentence1 &s1, const Sentence2
    &s2, double score_cutoff=0)
  • rapidfuzz::fuzz::token_sort_ratio β€” sorts the words in the strings and calculates the fuzz::ratio between them. order? never heard of her. πŸ¦‹
template<typename Sentence1, typename Sentence2> double
    rapidfuzz::fuzz::token_sort_ratio (const Sentence1 &s1, const
    Sentence2 &s2, double score_cutoff=0)
  • rapidfuzz::fuzz::partial_token_sort_ratio β€” sorts the words in the strings and calculates the fuzz::partial_ratio between them. the sort girlies and the partial girlies collabed and it ate. πŸ’–
template<typename Sentence1, typename Sentence2> double
    rapidfuzz::fuzz::partial_token_sort_ratio (const Sentence1 &s1,
    const Sentence2 &s2, double score_cutoff=0)
  • rapidfuzz::fuzz::token_set_ratio β€” compares the words in the strings based on unique and common words between them using fuzz::ratio. she's doing a whole venn diagram situation and honestly? valid. 🌸
template<typename Sentence1, typename Sentence2> double
    rapidfuzz::fuzz::token_set_ratio (const Sentence1 &s1, const
    Sentence2 &s2, double score_cutoff=0)
  • rapidfuzz::fuzz::partial_token_set_ratio β€” compares the words in the strings based on unique and common words between them using fuzz::partial_ratio. same venn diagram energy but she brought the partial flavor. πŸŽ€
template<typename Sentence1, typename Sentence2> double
    rapidfuzz::fuzz::partial_token_set_ratio (const Sentence1 &s1, const
    Sentence2 &s2, double score_cutoff=0)
  • rapidfuzz::fuzz::token_ratio β€” helper method that returns the maximum of fuzz::token_set_ratio and fuzz::token_sort_ratio (faster than manually executing the two functions). she just picks the winner for you and does it quicker, which is the definition of a supportive bestie. πŸ”₯
template<typename Sentence1, typename Sentence2> double
    rapidfuzz::fuzz::token_ratio (const Sentence1 &s1, const Sentence2
    &s2, double score_cutoff=0)
  • rapidfuzz::fuzz::partial_token_ratio β€” 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). same deal, partial edition, still faster than doing it by hand. periodt. πŸ’…
template<typename Sentence1, typename Sentence2> double
    rapidfuzz::fuzz::partial_token_ratio (const Sentence1 &s1, const
    Sentence2 &s2, double score_cutoff=0)
  • rapidfuzz::fuzz::WRatio β€” calculates a weighted ratio based on the other ratio algorithms. the "let me average the vibes of everyone else" algorithm. ⭐
template<typename Sentence1, typename Sentence2> double
    rapidfuzz::fuzz::WRatio (const Sentence1 &s1, const Sentence2 &s2,
    double score_cutoff=0)
  • rapidfuzz::fuzz::QRatio β€” calculates a quick ratio between two strings using fuzz.ratio. quick. in and out. no small talk. 🧚
template<typename Sentence1, typename Sentence2> double
    rapidfuzz::fuzz::QRatio (const Sentence1 &s1, const Sentence2 &s2,
    double score_cutoff=0)
lowkey note bestie: every single one of these caps out at a double return and takes that score_cutoff=0 default, so if you forget it, nobody's mad. 🫢

πŸ”₯ Detailed Description πŸ”₯

a collection of string matching algorithms from FuzzyWuzzy. πŸ’œ

like, that's the whole description, and honestly it understood the assignment. it's the FuzzyWuzzy algorithm lineup, ported into a rapid situation, and it's here to match your strings with speed and style. no cap. 🌈


<div align="center">🌸 to be continued in part 2 🌸</div>

wait no, that's a sign-off, and we're not doing that. anyway β€” the fuzz:: namespace is literally the moment, and every function above is a different flavor of "how similar are these two strings actually", each one with its own whole personality. iykyk. πŸ¦‹

✨ Function Documentation ✨

Okay bestie, this is the main character energy section πŸ’… β€” every single ratio function RapidFuzz has for you. They're all templates, they all live in #include <fuzz.hpp>, and they all share the exact same score_cutoff situation. Let's take them one by one, no skips, no cap 🫢


πŸ’– rapidfuzz::fuzz::partial_ratio πŸ’–

template<typename Sentence1, typename Sentence2>
double rapidfuzz::fuzz::partial_ratio (const Sentence1 & s1, const Sentence2 & s2, double score_cutoff = 0)

#include <fuzz.hpp>

Calculates the fuzz::ratio of the optimal string alignment test, per the sources [hyrro_2004] [wagner_fischer_1974] πŸ“š

Like, watch:

// score is 100
double score = partial_ratio("this is a test", "this is a test!")

Template Parameters

  • Sentence1 β€” this is a string that can be converted to basic_string_view<char_type>
  • Sentence2 β€” this is a string that can be converted to basic_string_view<char_type>

Parameters

  • s1 β€” the string you're comparing against s2 (for type info, peek the template parameters above)
  • s2 β€” the string you're comparing against s1 (same, check the template parameters above)
  • score_cutoff β€” optional 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


πŸ¦‹ rapidfuzz::fuzz::partial_token_ratio πŸ¦‹

template<typename Sentence1, typename Sentence2>
double rapidfuzz::fuzz::partial_token_ratio (const Sentence1 & s1, const Sentence2 & s2, double score_cutoff = 0)

#include <fuzz.hpp>

Helper method that returns the maximum of fuzz::partial_token_set_ratio and fuzz::partial_token_sort_ratio β€” and it's faster than manually executing the two functions, so like, why would you πŸ™ˆ

Template Parameters

  • Sentence1 β€” a string convertible to basic_string_view<char_type>
  • Sentence2 β€” a string convertible to basic_string_view<char_type>

Parameters

  • s1 β€” string to compare with s2 (for type info check Template parameters above)
  • s2 β€” string to compare with s1 (for type info check Template parameters above)
  • score_cutoff β€” optional 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


πŸŽ€ rapidfuzz::fuzz::partial_token_set_ratio πŸŽ€

template<typename Sentence1, typename Sentence2>
double rapidfuzz::fuzz::partial_token_set_ratio (const Sentence1 & s1, const Sentence2 & s2, double score_cutoff = 0)

#include <fuzz.hpp>

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

Template Parameters

  • Sentence1 β€” this is a string that can be converted to basic_string_view<char_type>
  • Sentence2 β€” this is a string that can be converted to basic_string_view<char_type>

Parameters

  • s1 β€” string to compare with s2 (for type info check Template parameters above)
  • s2 β€” string to compare with s1 (for type info check Template parameters above)
  • score_cutoff β€” optional 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


🌸 rapidfuzz::fuzz::partial_token_sort_ratio 🌸

template<typename Sentence1, typename Sentence2>
double rapidfuzz::fuzz::partial_token_sort_ratio (const Sentence1 & s1, const Sentence2 & s2, double score_cutoff = 0)

#include <fuzz.hpp>

Sorts the words in the strings, then calculates the fuzz::partial_ratio between them ✨

Template Parameters

  • Sentence1 β€” a string that can be converted to basic_string_view<char_type>
  • Sentence2 β€” a string that can be converted to basic_string_view<char_type>

Parameters

  • s1 β€” string to compare with s2 (for type info check Template parameters above)
  • s2 β€” string to compare with s1 (for type info check Template parameters above)
  • score_cutoff β€” optional 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


πŸ‘‘ rapidfuzz::fuzz::QRatio πŸ‘‘

template<typename Sentence1, typename Sentence2>
double rapidfuzz::fuzz::QRatio (const Sentence1 & s1, const Sentence2 & s2, double score_cutoff = 0)

#include <fuzz.hpp>

Calculates a quick ratio between two strings using fuzz.ratio ⚑ (yes bestie, the Q stands for quick, we love an efficiency icon)

Template Parameters

  • Sentence1 β€” this is a string that can be converted to basic_string_view<char_type>
  • Sentence2 β€” this is a string that can be converted to basic_string_view<char_type>

Parameters

  • s1 β€” string to compare with s2 (for type info check Template parameters above)
  • s2 β€” string to compare with s1 (for type info check Template parameters above)
  • score_cutoff β€” optional 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


πŸ’œ rapidfuzz::fuzz::ratio πŸ’œ

template<typename Sentence1, typename Sentence2>
double rapidfuzz::fuzz::ratio (const Sentence1 & s1, const Sentence2 & s2, double score_cutoff = 0)

#include <fuzz.hpp>

Calculates a simple ratio between two strings 🌈

// score is 96.55
double score = ratio("this is a test", "this is a test!")

Template Parameters

  • Sentence1 β€” a string that can be converted to basic_string_view<char_type>
  • Sentence2 β€” a string that can be converted to basic_string_view<char_type>

Parameters

  • s1 β€” string to compare with s2 (for type info check Template parameters above)
  • s2 β€” string to compare with s1 (for type info check Template parameters above)
  • score_cutoff β€” optional 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


πŸ“ rapidfuzz::fuzz::token_ratio πŸ“

template<typename Sentence1, typename Sentence2>
double rapidfuzz::fuzz::token_ratio (const Sentence1 & s1, const Sentence2 & s2, double score_cutoff = 0)

#include <fuzz.hpp>

Helper method that returns the maximum of fuzz::token_set_ratio and fuzz::token_sort_ratio β€” and it's faster than manually executing the two functions, so it's giving "do less, get more" πŸ’…

Template Parameters

  • Sentence1 β€” this is a string that can be converted to basic_string_view<char_type>
  • Sentence2 β€” this is a string that can be converted to basic_string_view<char_type>

Parameters

  • s1 β€” string to compare with s2 (for type info check Template parameters above)
  • s2 β€” string to compare with s1 (for type info check Template parameters above)
  • score_cutoff β€” optional 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


🧚 rapidfuzz::fuzz::token_set_ratio 🧚

template<typename Sentence1, typename Sentence2>
double rapidfuzz::fuzz::token_set_ratio (const Sentence1 & s1, const Sentence2 & s2, double score_cutoff = 0)

#include <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")

Template Parameters

  • Sentence1 β€” a string that can be converted to basic_string_view<char_type>
  • Sentence2 β€” a string that can be converted to basic_string_view<char_type>

Parameters

  • s1 β€” string to compare with s2 (for type info check Template parameters above)
  • s2 β€” string to compare with s1 (for type info check Template parameters above)
  • score_cutoff β€” optional 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


🫢 rapidfuzz::fuzz::token_sort_ratio 🫢

template<typename Sentence1, typename Sentence2>
double rapidfuzz::fuzz::token_sort_ratio (const Sentence1 & s1, const Sentence2 & s2, double score_cutoff = 0)

#include <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

  • Sentence1 β€” this is a string that can be converted to basic_string_view<char_type>
  • Sentence2 β€” this is a string that can be converted to basic_string_view<char_type>

Parameters

  • s1 β€” string to compare with s2 (for type info check Template parameters above)
  • s2 β€” string to compare with s1 (for type info check Template parameters above)
  • score_cutoff β€” optional 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


⭐ rapidfuzz::fuzz::WRatio ⭐

template<typename Sentence1, typename Sentence2>
double rapidfuzz::fuzz::WRatio (const Sentence1 & s1, const Sentence2 & s2, double score_cutoff = 0)

#include <fuzz.hpp>

Calculates a weighted ratio based on the other ratio algorithms πŸ”₯ (yes it's the whole squad rolled into one, main character behaviour fr fr)

Template Parameters

  • Sentence1 β€” a string that can be converted to basic_string_view<char_type>
  • Sentence2 β€” a string that can be converted to basic_string_view<char_type>

Parameters

  • s1 β€” string to compare with s2 (for type info check Template parameters above)
  • s2 β€” string to compare with s1 (for type info check Template parameters above)
  • score_cutoff β€” optional 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


🌈 Author 🌈

Generated automatically by Doxygen for RapidFuzz from the source code. So no, a human didn't hand-write this one β€” Doxygen did, and honestly? It ate πŸ’…


And that's the whole page bestie, you made it to the end πŸ₯³ This absolute unit of a manual page is a RapidFuzz production, filed under rapidfuzz(3) in your friendly neighbourhood section 3 β€” so go forth and fuzzy-match everything, and remember: score_cutoff is your friend, defaults are 0, and 0 is returned when the ratio falls below it. Periodt πŸ’–βœ¨

πŸ“¦ where this page comes from