Fix Indel.normalized_similarity

This commit is contained in:
Max Bachmann 2022-02-11 16:02:00 +01:00
parent 9886cba1b9
commit 4444f3411f
7 changed files with 33 additions and 7 deletions

View File

@ -1,10 +1,11 @@
## Changelog
### [2.1.0] - Unreleased
### [2.0.1] - 2022-02-11
#### Fixed
- fix type hints
- Indel.normalized_similarity mistakenly used the implementation of Indel.normalized_distance
### [2.0.0] - 2022-01-09
### [2.0.0] - 2022-02-09
#### Added
- added C-Api which can be used to extend RapidFuzz from different Python modules using any
programming language which allows the usage of C-Apis (C/C++/Rust)

View File

@ -22,7 +22,7 @@ copyright = '2021, Max Bachmann'
author = 'Max Bachmann'
# The full version, including alpha/beta/rc tags
release = '2.0.0'
release = '2.0.1'
# -- General configuration ---------------------------------------------------

@ -1 +1 @@
Subproject commit 5083fb7b495072871d3c22af16e2d5ddd84c9cb7
Subproject commit b2240f75cb0308cdf928ead4e1f6422a7a3c4efa

View File

@ -6,7 +6,7 @@ with open('README.md', 'rt', encoding="utf8") as f:
setup(
name="rapidfuzz",
version="2.0.0",
version="2.0.1",
extras_require={'full': ['numpy']},
url="https://github.com/maxbachmann/RapidFuzz",
author="Max Bachmann",

View File

@ -234,7 +234,7 @@ def normalized_similarity(s1, s2, *, processor=None, score_cutoff=None):
raise ValueError("score_cutoff has to be >= 0")
preprocess_strings(s1, s2, processor, &s1_proc, &s2_proc)
return indel_normalized_distance_func(s1_proc.string, s2_proc.string, c_score_cutoff)
return indel_normalized_similarity_func(s1_proc.string, s2_proc.string, c_score_cutoff)
def editops(s1, s2, *, processor=None):
"""

View File

@ -3,7 +3,7 @@ rapid string matching library
"""
__author__ = "Max Bachmann"
__license__ = "MIT"
__version__ = "2.0.0"
__version__ = "2.0.1"
from rapidfuzz import (
process,

View File

@ -0,0 +1,25 @@
import unittest
from rapidfuzz.distance import Indel
def test_similar_strings():
"""
Test similar strings
"""
assert Indel.distance("test", "test") == 0
assert Indel.similarity("test", "test") == 8
assert Indel.normalized_distance("test", "test") == 0
assert Indel.normalized_similarity("test", "test") == 1.0
def test_different_strings():
"""
Test completly different strings
"""
assert Indel.distance("aaaa", "bbbb") == 8
assert Indel.similarity("aaaa", "bbbb") == 0
assert Indel.normalized_distance("aaaa", "bbbb") == 1.0
assert Indel.normalized_similarity("aaaa", "bbbb") == 0.0
if __name__ == '__main__':
unittest.main()