Beispiel #1
0
    def test_case_insensitive(self):
        """Function should be case insensitive"""
        names = ["Robert", "Rupert", "Rubin", "Ashcraft", "Ashcroft"]

        for name in names:
            self.assertEqual(fuzzycomp.soundex(name.lower()),
                             fuzzycomp.soundex(name.upper()))
Beispiel #2
0
    def test_same_code(self):
        """All listed names should produce the same soundex code"""
        name_lists = []

        for names in name_lists:
            code = fuzzycomp.soundex(names[0])
            for name in names:
                self.assertEqual(fuzzycomp.soundex(name), code)
Beispiel #3
0
    def test_same_code(self):
        """All listed names should produce the same soundex code"""
        name_lists = []

        for names in name_lists:
            code = fuzzycomp.soundex(names[0])
            for name in names:
                self.assertEqual(fuzzycomp.soundex(name), code)
Beispiel #4
0
    def test_ignore_bad_chars(self):
        """Un-encodable  characters should be ignored"""
        strings = ["HOLMES", "H-OLMES", "HO-LMES", "HOL-MES", "HOLM-ES", "HOLME-S", "HOLMES-"]
        result = "H452"

        for s in strings:
            self.assertEqual(fuzzycomp.soundex(s), result)

        self.assertEqual(fuzzycomp.soundex("HOL>MES"), result)
        self.assertEqual(fuzzycomp.soundex("HOLM<ES"), result)
        self.assertEqual(fuzzycomp.soundex("HOL|MES"), result)

        for s in ["'OBrien", "'OBrien", "O'Brien", "OB'rien", "OBr'ien", "OBri'en", "OBrie'n", "OBrien'"]:
            self.assertEqual(fuzzycomp.soundex(s), "O165")
Beispiel #5
0
    def test_valid_input(self):
        """Algorithm should return correct values under valid input"""
        data = [('HERMAN', 'H650'), ('Robert', 'R163'), ('Rupert', 'R163'),
                ('Rubin', 'R150'), ('Ashcraft', 'A261'), ('Ashcroft', 'A261')]

        for d in data:
            self.assertEqual(fuzzycomp.soundex(d[0]), d[1])
Beispiel #6
0
    def test_ignore_bad_chars(self):
        """Un-encodable  characters should be ignored"""
        strings = [
            "HOLMES", "H-OLMES", "HO-LMES", "HOL-MES", "HOLM-ES", "HOLME-S",
            "HOLMES-"
        ]
        result = "H452"

        for s in strings:
            self.assertEqual(fuzzycomp.soundex(s), result)

        self.assertEqual(fuzzycomp.soundex("HOL>MES"), result)
        self.assertEqual(fuzzycomp.soundex("HOLM<ES"), result)
        self.assertEqual(fuzzycomp.soundex("HOL|MES"), result)

        for s in [
                "'OBrien", "'OBrien", "O'Brien", "OB'rien", "OBr'ien",
                "OBri'en", "OBrie'n", "OBrien'"
        ]:
            self.assertEqual(fuzzycomp.soundex(s), "O165")
Beispiel #7
0
    def test_valid_input(self):
        """Algorithm should return correct values under valid input"""
        data = [
            ("HERMAN", "H650"),
            ("Robert", "R163"),
            ("Rupert", "R163"),
            ("Rubin", "R150"),
            ("Ashcraft", "A261"),
            ("Ashcroft", "A261"),
        ]

        for d in data:
            self.assertEqual(fuzzycomp.soundex(d[0]), d[1])
Beispiel #8
0
    def test_case_insensitive(self):
        """Function should be case insensitive"""
        names = ["Robert", "Rupert", "Rubin", "Ashcraft", "Ashcroft"]

        for name in names:
            self.assertEqual(fuzzycomp.soundex(name.lower()), fuzzycomp.soundex(name.upper()))
Beispiel #9
0
 def test_ignore_trimmables(self):
     """Function should ignore white-space before and after the word"""
     self.assertEqual(fuzzycomp.soundex("Rubin"), fuzzycomp.soundex("\t\r\n  Rubin \t\r\n"))
Beispiel #10
0
 def test_ignore_trimmables(self):
     """Function should ignore white-space before and after the word"""
     self.assertEqual(fuzzycomp.soundex("Rubin"),
                      fuzzycomp.soundex("\t\r\n  Rubin \t\r\n"))