Example #1
0
    def testQRatioForceAscii(self):
        s1 = "ABCD\u00C1"
        s2 = "ABCD"

        score = fuzz.WRatio(s1, s2, force_ascii=True)
        self.assertEqual(score, 100)

        score = fuzz.WRatio(s1, s2, force_ascii=False)
        self.assertLess(score, 100)
Example #2
0
    def testWRatioUnicodeString(self):
        s1 = "\u00C1"
        s2 = "ABCD"
        score = fuzz.WRatio(s1, s2)
        self.assertEqual(0, score)

        # Cyrillic.
        s1 = "\u043f\u0441\u0438\u0445\u043e\u043b\u043e\u0433"
        s2 = "\u043f\u0441\u0438\u0445\u043e\u0442\u0435\u0440\u0430\u043f\u0435\u0432\u0442"
        score = fuzz.WRatio(s1, s2, force_ascii=False)
        self.assertNotEqual(0, score)

        # Chinese.
        s1 = "\u6211\u4e86\u89e3\u6570\u5b66"
        s2 = "\u6211\u5b66\u6570\u5b66"
        score = fuzz.WRatio(s1, s2, force_ascii=False)
        self.assertNotEqual(0, score)
Example #3
0
 def testQRatioUnicode(self):
     self.assertEqual(fuzz.WRatio(unicode(self.s1), unicode(self.s1a)), 100)
Example #4
0
 def testWRatioMisorderedMatch(self):
     # misordered full matches are scaled by .95
     self.assertEqual(fuzz.WRatio(self.s4, self.s5), 95)
Example #5
0
 def testWRatioPartialMatch(self):
     # a partial match is scaled by .9
     self.assertEqual(fuzz.WRatio(self.s1, self.s3), 90)
Example #6
0
 def testWRatioCaseInsensitive(self):
     self.assertEqual(fuzz.WRatio(self.s1, self.s2), 100)
Example #7
0
 def testWRatioEqual(self):
     self.assertEqual(fuzz.WRatio(self.s1, self.s1a), 100)