Skip to content

Commit 2c8c070

Browse files
jlb52maxbachmann
authored andcommitted
Adds examples to token_set_ratio
1 parent c459f9a commit 2c8c070

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ Scorers in RapidFuzz can be found in the modules `fuzz` and `distance`.
130130
84.21052631578947
131131
> fuzz.token_set_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
132132
100.0
133+
# Returns 100.0 if one string is a subset of the other, regardless of extra content in the longer string
134+
> fuzz.token_set_ratio("fuzzy was a bear but not a dog", "fuzzy was a bear")
135+
100.0
136+
# Score is reduced only when there is explicit disagreement in the two strings
137+
> fuzz.token_set_ratio("fuzzy was a bear but not a dog", "fuzzy was a bear but not a cat")
138+
92.3076923076923
133139
```
134140

135141
#### Weighted Ratio

src/rapidfuzz/fuzz_py.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ def token_set_ratio(
434434
83.8709716796875
435435
>>> fuzz.token_set_ratio("fuzzy was a bear", "fuzzy fuzzy was a bear")
436436
100.0
437+
# Returns 100.0 if one string is a subset of the other, regardless of extra content in the longer string
438+
>>> fuzz.token_set_ratio("fuzzy was a bear but not a dog", "fuzzy was a bear")
439+
100.0
440+
# Score is reduced only when there is explicit disagreement in the two strings
441+
>>> fuzz.token_set_ratio("fuzzy was a bear but not a dog", "fuzzy was a bear but not a cat")
442+
92.3076923076923
437443
"""
438444
setupPandas()
439445
if is_none(s1) or is_none(s2):

0 commit comments

Comments
 (0)