Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

error in partial_ratio. closes #7

  • Loading branch information...
commit 9d0912fe75f017190950012d2a999bbc7e501ce6 1 parent 71d2838
Adam Cohen authored December 19, 2011
3  fuzzywuzzy/fuzz.py
@@ -67,8 +67,7 @@ def partial_ratio(s1,  s2):
67 67
     #   best score === ratio("abcd", "Xbcd")
68 68
     scores = []
69 69
     for block in blocks:
70  
-
71  
-        long_start   = block[1] - block[0]
  70
+        long_start   = block[1] - block[0] if (block[1] - block[0]) > 0 else 0
72 71
         long_end     = long_start + len(shorter)
73 72
         long_substr  = longer[long_start:long_end]
74 73
 
12  fuzzywuzzy/tests.py
@@ -24,7 +24,7 @@ def setUp(self):
24 24
             u"\xacCamarões assados",
25 25
             u"a\xac\u1234\u20ac\U00008000"
26 26
             ]
27  
-        
  27
+
28 28
 
29 29
     def tearDown(self):
30 30
         pass
@@ -109,6 +109,16 @@ def testWRatioMisorderedMatch(self):
109 109
         # misordered full matches are scaled by .95
110 110
         self.assertEqual(WRatio(self.s4, self.s5), 95)
111 111
 
  112
+    def testIssueSeven(self):
  113
+        s1 = "HSINCHUANG"
  114
+        s2 = "SINJHUAN"
  115
+        s3 = "LSINJHUANG DISTRIC"
  116
+        s4 = "SINJHUANG DISTRICT"
  117
+
  118
+        self.assertGreater(partial_ratio(s1, s2), 75)
  119
+        self.assertGreater(partial_ratio(s1, s3), 75)
  120
+        self.assertGreater(partial_ratio(s1, s4), 75)
  121
+
112 122
     # test processing methods
113 123
     def testGetBestChoice1(self):
114 124
         query = "new york mets at atlanta braves"

0 notes on commit 9d0912f

Please sign in to comment.
Something went wrong with that request. Please try again.