Exemplo n.º 1
0
    def test_case_insensitive(self):
        """Function should be case insensitive"""
        names = [
            "Wade",
            "Wait",
            "Alberik",
            "Albert",
            "Cari",
            "Caria",
            "Ginnie",
            "Ginny",
            "Nat",
            "Nata",
            "Natty",
            "Meara",
            "Merrie",
            "Pearcy",
            "Perris",
            "Susana",
            "Susann",
            "Rudd",
            "Ryde",
            "Selena",
            "Selene",
        ]

        for name in names:
            self.assertEqual(fuzzycomp.metaphone(name.lower()), fuzzycomp.metaphone(name.upper()))
Exemplo n.º 2
0
    def test_equal_code(self):
        """All listed names should produce the same Metaphone key"""

        name_list = [
            ("White", "Wade", "Wait", "Waite", "Wat", "Whit", "Wiatt", "Wit",
             "Wittie", "Witty"),
            ("Albert", "Ailbert", "Alberik", "Albert", "Alberto"),
            ("Gary", "Carie", "Caro", "Carree", "Carri", "Carrie", "Carry",
             "Cary", "Cora", "Corey", "Cori", "Corie", "Correy"),
            ("John", "Gina", "Ginni", "Ginnie", "Ginny", "Jaine", "Jan",
             "Jana", "Jane", "Janey", "Jania", "Janie", "Janna", "Jany",
             "Jayne"),
            ("Knight", "Nat", "Nata", "Natty", "Neda", "Nedda", "Nedi",
             "Netta", "Netti"),
            ("Mary", "Mari", "Maria", "Marie", "Mary", "Maura", "Maure",
             "Meara", "Merrie", "Merry", "Mira", "Moira"),
            ("Paris", "Pearcy", "Perris", "Piercy", "Pierz", "Pryse"),
            ("Peter", "Peadar", "Peder", "Pedro", "Peter", "Petr", "Peyter",
             "Pieter", "Pietro"), ("Ray", "Ray", "Rey", "Roi", "Roy", "Ruy"),
            ("Susan", "Susan", "Susana", "Susann", "Susanna", "Susannah",
             "Susanne", "Suzann"), ("Wright", "Rota", "Rudd", "Ryde"),
            ("Xalan", "Selena", "Selene", "Selina", "Seline", "Suellen")
        ]

        for names in name_list:
            code = fuzzycomp.metaphone(names[0])
            for name in names:
                _c = fuzzycomp.metaphone(name)
                self.assertEquals(_c, code)
Exemplo n.º 3
0
    def test_non_encodable_chars(self):
        """Non-encodable chars should be ignored"""
        names = ["-testing", "t-esting", "te-sting", "tes-ting", "test-ing", "testi-ng", "testin-g", "testing-"]
        key = "TSTN"
        for name in names:
            self.assertEquals(fuzzycomp.metaphone(name), key)

        self.assertEquals(fuzzycomp.metaphone("test>ing"), key)
Exemplo n.º 4
0
    def test_case_insensitive(self):
        """Function should be case insensitive"""
        names = [
            "Wade", "Wait", "Alberik", "Albert", "Cari", "Caria", "Ginnie",
            "Ginny", "Nat", "Nata", "Natty", "Meara", "Merrie", "Pearcy",
            "Perris", "Susana", "Susann", "Rudd", "Ryde", "Selena", "Selene"
        ]

        for name in names:
            self.assertEqual(fuzzycomp.metaphone(name.lower()),
                             fuzzycomp.metaphone(name.upper()))
Exemplo n.º 5
0
    def test_non_encodable_chars(self):
        """Non-encodable chars should be ignored"""
        names = [
            "-testing", "t-esting", "te-sting", "tes-ting", "test-ing",
            "testi-ng", "testin-g", "testing-"
        ]
        key = "TSTN"
        for name in names:
            self.assertEquals(fuzzycomp.metaphone(name), key)

        self.assertEquals(fuzzycomp.metaphone("test>ing"), key)
Exemplo n.º 6
0
    def test_equal_code(self):
        """All listed names should produce the same Metaphone key"""

        name_list = [
            ("White", "Wade", "Wait", "Waite", "Wat", "Whit", "Wiatt", "Wit", "Wittie", "Witty"),
            ("Albert", "Ailbert", "Alberik", "Albert", "Alberto"),
            (
                "Gary",
                "Carie",
                "Caro",
                "Carree",
                "Carri",
                "Carrie",
                "Carry",
                "Cary",
                "Cora",
                "Corey",
                "Cori",
                "Corie",
                "Correy",
            ),
            (
                "John",
                "Gina",
                "Ginni",
                "Ginnie",
                "Ginny",
                "Jaine",
                "Jan",
                "Jana",
                "Jane",
                "Janey",
                "Jania",
                "Janie",
                "Janna",
                "Jany",
                "Jayne",
            ),
            ("Knight", "Nat", "Nata", "Natty", "Neda", "Nedda", "Nedi", "Netta", "Netti"),
            ("Mary", "Mari", "Maria", "Marie", "Mary", "Maura", "Maure", "Meara", "Merrie", "Merry", "Mira", "Moira"),
            ("Paris", "Pearcy", "Perris", "Piercy", "Pierz", "Pryse"),
            ("Peter", "Peadar", "Peder", "Pedro", "Peter", "Petr", "Peyter", "Pieter", "Pietro"),
            ("Ray", "Ray", "Rey", "Roi", "Roy", "Ruy"),
            ("Susan", "Susan", "Susana", "Susann", "Susanna", "Susannah", "Susanne", "Suzann"),
            ("Wright", "Rota", "Rudd", "Ryde"),
            ("Xalan", "Selena", "Selene", "Selina", "Seline", "Suellen"),
        ]

        for names in name_list:
            code = fuzzycomp.metaphone(names[0])
            for name in names:
                _c = fuzzycomp.metaphone(name)
                self.assertEquals(_c, code)
Exemplo n.º 7
0
 def test_trimmable_chars(self):
     """Function should ignore trimmable chars in front and after the string"""
     names = [("\r\t\n       RANDY \r\t\n    ", "RNT"),
              ("\r\t\n    CAMBRILLO\r\t\n    ", "KMBR"),
              ("\r\t\n    BRIAN\r\t\n    ", "BRN"),
              ("\r\t\n    RAY\r\t\n    ", "R")]
     for name in names:
         self.assertEquals(fuzzycomp.metaphone(name[0]), name[1])
Exemplo n.º 8
0
 def test_trimmable_chars(self):
     """Function should ignore trimmable chars in front and after the string"""
     names = [
         ("\r\t\n       RANDY \r\t\n    ", "RNT"),
         ("\r\t\n    CAMBRILLO\r\t\n    ", "KMBR"),
         ("\r\t\n    BRIAN\r\t\n    ", "BRN"),
         ("\r\t\n    RAY\r\t\n    ", "R"),
     ]
     for name in names:
         self.assertEquals(fuzzycomp.metaphone(name[0]), name[1])
Exemplo n.º 9
0
 def test_longer_codes(self):
     """Function should return correct values when longer codes are used"""
     self.assertEqual(fuzzycomp.metaphone("DAVIS-CARTER", 7), "TFSKRTR")
     self.assertEqual(fuzzycomp.metaphone("DAVIS-CARTER", 6), "TFSKRT")
     self.assertEqual(fuzzycomp.metaphone("DAVIS-CARTER", 5), "TFSKR")
     self.assertEqual(fuzzycomp.metaphone("ESCARMANT", 7), "ESKRMNT")
     self.assertEqual(fuzzycomp.metaphone("STARLEPER", 6), "STRLPR")
     self.assertEqual(fuzzycomp.metaphone("CAMBRILLO", 5), "KMBRL")
     self.assertEqual(fuzzycomp.metaphone("BRYCE", 7), "BRS")
Exemplo n.º 10
0
 def test_longer_codes(self):
     """Function should return correct values when longer codes are used"""
     self.assertEqual(fuzzycomp.metaphone("DAVIS-CARTER", 7), "TFSKRTR")
     self.assertEqual(fuzzycomp.metaphone("DAVIS-CARTER", 6), "TFSKRT")
     self.assertEqual(fuzzycomp.metaphone("DAVIS-CARTER", 5), "TFSKR")
     self.assertEqual(fuzzycomp.metaphone("ESCARMANT", 7), "ESKRMNT")
     self.assertEqual(fuzzycomp.metaphone("STARLEPER", 6), "STRLPR")
     self.assertEqual(fuzzycomp.metaphone("CAMBRILLO", 5), "KMBRL")
     self.assertEqual(fuzzycomp.metaphone("BRYCE", 7), "BRS")
Exemplo n.º 11
0
 def test_non_encodable_strings(self):
     """Function should return an empty string if it can not be encoded"""
     self.assertEqual(fuzzycomp.metaphone("!&(#=#/%#?+§"), "")
     for char in "!&(#=#/%#?+§":
         self.assertEqual(fuzzycomp.metaphone(char), "")
Exemplo n.º 12
0
 def test_unicode(self):
     """Function should return valid results when passed valid unicode data"""
     for name in self.names:
         self.assertEquals(fuzzycomp.metaphone(unicode(name[0])), name[1])
Exemplo n.º 13
0
 def test_valid_input(self):
     """Algorithm should return correct values under valid input"""
     for name in self.names:
         self.assertEquals(fuzzycomp.metaphone(name[0]), name[1])
Exemplo n.º 14
0
 def test_non_encodable_strings(self):
     """Function should return an empty string if it can not be encoded"""
     self.assertEqual(fuzzycomp.metaphone("!&(#=#/%#?+§"), "")
     for char in "!&(#=#/%#?+§":
         self.assertEqual(fuzzycomp.metaphone(char), "")
Exemplo n.º 15
0
 def test_unicode(self):
     """Function should return valid results when passed valid unicode data"""
     for name in self.names:
         self.assertEquals(fuzzycomp.metaphone(unicode(name[0])), name[1])
Exemplo n.º 16
0
 def test_valid_input(self):
     """Algorithm should return correct values under valid input"""
     for name in self.names:
         self.assertEquals(fuzzycomp.metaphone(name[0]), name[1])