Skip to content

Commit

Permalink
Fix Indel.normalized_similarity
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbachmann committed Feb 11, 2022
1 parent 9886cba commit 4444f34
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Max Bachmann'

# The full version, including alpha/beta/rc tags
release = '2.0.0'
release = '2.0.1'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion extern/rapidfuzz-cpp
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="rapidfuzz",
version="2.0.0",
version="2.0.1",
extras_require={'full': ['numpy']},
url="https://github.com/maxbachmann/RapidFuzz",
author="Max Bachmann",
Expand Down
2 changes: 1 addition & 1 deletion src/cython/distance/Indel.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/rapidfuzz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
__author__ = "Max Bachmann"
__license__ = "MIT"
__version__ = "2.0.0"
__version__ = "2.0.1"

from rapidfuzz import (
process,
Expand Down
25 changes: 25 additions & 0 deletions tests/distance/test_Indel.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 4444f34

Please sign in to comment.