Skip to content

Commit

Permalink
Adds examples to token_set_ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
jlb52 authored and maxbachmann committed May 28, 2024
1 parent c459f9a commit 2c8c070
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ Scorers in RapidFuzz can be found in the modules `fuzz` and `distance`.
84.21052631578947
> fuzz.token_set_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
100.0
# Returns 100.0 if one string is a subset of the other, regardless of extra content in the longer string
> fuzz.token_set_ratio("fuzzy was a bear but not a dog", "fuzzy was a bear")
100.0
# Score is reduced only when there is explicit disagreement in the two strings
> fuzz.token_set_ratio("fuzzy was a bear but not a dog", "fuzzy was a bear but not a cat")
92.3076923076923
```

#### Weighted Ratio
Expand Down
6 changes: 6 additions & 0 deletions src/rapidfuzz/fuzz_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ def token_set_ratio(
83.8709716796875
>>> fuzz.token_set_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
100.0
# Returns 100.0 if one string is a subset of the other, regardless of extra content in the longer string
>>> fuzz.token_set_ratio("fuzzy was a bear but not a dog", "fuzzy was a bear")
100.0
# Score is reduced only when there is explicit disagreement in the two strings
>>> fuzz.token_set_ratio("fuzzy was a bear but not a dog", "fuzzy was a bear but not a cat")
92.3076923076923
"""
setupPandas()
if is_none(s1) or is_none(s2):
Expand Down

0 comments on commit 2c8c070

Please sign in to comment.