Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
error in partial_ratio. closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Cohen committed Dec 20, 2011
1 parent 71d2838 commit 9d0912f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 1 addition & 2 deletions fuzzywuzzy/fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ def partial_ratio(s1, s2):
# best score === ratio("abcd", "Xbcd")
scores = []
for block in blocks:

long_start = block[1] - block[0]
long_start = block[1] - block[0] if (block[1] - block[0]) > 0 else 0
long_end = long_start + len(shorter)
long_substr = longer[long_start:long_end]

Expand Down
12 changes: 11 additions & 1 deletion fuzzywuzzy/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def setUp(self):
u"\xacCamarões assados",
u"a\xac\u1234\u20ac\U00008000"
]


def tearDown(self):
pass
Expand Down Expand Up @@ -109,6 +109,16 @@ def testWRatioMisorderedMatch(self):
# misordered full matches are scaled by .95
self.assertEqual(WRatio(self.s4, self.s5), 95)

def testIssueSeven(self):
s1 = "HSINCHUANG"
s2 = "SINJHUAN"
s3 = "LSINJHUANG DISTRIC"
s4 = "SINJHUANG DISTRICT"

self.assertGreater(partial_ratio(s1, s2), 75)
self.assertGreater(partial_ratio(s1, s3), 75)
self.assertGreater(partial_ratio(s1, s4), 75)

# test processing methods
def testGetBestChoice1(self):
query = "new york mets at atlanta braves"
Expand Down

0 comments on commit 9d0912f

Please sign in to comment.