Ejemplo n.º 1
0
 'davidson': Davidson().encode,
 'dolby': Dolby().encode,
 'dolby_ml4': Dolby(max_length=4).encode,
 'dolby_vowels': Dolby(keep_vowels=True).encode,
 'double_metaphone': DoubleMetaphone().encode,
 'eudex': Eudex().encode,
 'fonem': FONEM().encode,
 'fuzzy_soundex': FuzzySoundex().encode,
 'fuzzy_soundex_0pad_ml8': FuzzySoundex(max_length=8, zero_pad=True).encode,
 'haase_phonetik': Haase().encode,
 'haase_phonetik_primary': Haase(primary_only=True).encode,
 'henry_early': HenryEarly().encode,
 'henry_early_ml8': HenryEarly(max_length=8).encode,
 'koelner_phonetik': Koelner().encode,
 'koelner_phonetik_alpha': Koelner().encode_alpha,
 'lein': LEIN().encode,
 'lein_nopad_ml8': LEIN(max_length=8, zero_pad=False).encode,
 'metasoundex': MetaSoundex().encode,
 'metasoundex_es': MetaSoundex(lang='es').encode,
 'metaphone': Metaphone().encode,
 'mra': MRA().encode,
 'norphone': Norphone().encode,
 'nrl': NRL().encode,
 'nysiis': NYSIIS().encode,
 'nysiis_modified': NYSIIS(modified=True).encode,
 'nysiis_ml_inf': NYSIIS(max_length=-1).encode,
 'onca': ONCA().encode,
 'onca_nopad_ml8': ONCA(max_length=8, zero_pad=False).encode,
 'parmar_kumbharana': ParmarKumbharana().encode,
 'phonem': Phonem().encode,
 'phonet_1': Phonet().encode,
Ejemplo n.º 2
0
class LeinTestCases(unittest.TestCase):
    """Test LEIN functions.

    test cases for abydos.phonetic.LEIN
    """

    pa = LEIN()
    pa_n0 = LEIN(zero_pad=False)

    def test_lein(self):
        """Test abydos.phonetic.LEIN."""
        self.assertEqual(self.pa.encode(''), '0000')

        # https://naldc.nal.usda.gov/download/27833/PDF
        self.assertEqual(self.pa.encode('Dubose'), 'D450')
        self.assertEqual(self.pa.encode('Dubs'), 'D450')
        self.assertEqual(self.pa.encode('Dubbs'), 'D450')
        self.assertEqual(self.pa.encode('Doviak'), 'D450')
        self.assertEqual(self.pa.encode('Dubke'), 'D450')
        self.assertEqual(self.pa.encode('Dubus'), 'D450')
        self.assertEqual(self.pa.encode('Dubois'), 'D450')
        self.assertEqual(self.pa.encode('Duboise'), 'D450')
        self.assertEqual(self.pa.encode('Doubek'), 'D450')
        self.assertEqual(self.pa.encode('Defigh'), 'D450')
        self.assertEqual(self.pa.encode('Defazio'), 'D450')
        self.assertEqual(self.pa.encode('Debaca'), 'D450')
        self.assertEqual(self.pa.encode('Dabbs'), 'D450')
        self.assertEqual(self.pa.encode('Davies'), 'D450')
        self.assertEqual(self.pa.encode('Dubukey'), 'D450')
        self.assertEqual(self.pa.encode('Debus'), 'D450')
        self.assertEqual(self.pa.encode('Debose'), 'D450')
        self.assertEqual(self.pa.encode('Daves'), 'D450')
        self.assertEqual(self.pa.encode('Dipiazza'), 'D450')
        self.assertEqual(self.pa.encode('Dobbs'), 'D450')
        self.assertEqual(self.pa.encode('Dobak'), 'D450')
        self.assertEqual(self.pa.encode('Dobis'), 'D450')
        self.assertEqual(self.pa.encode('Dobish'), 'D450')
        self.assertEqual(self.pa.encode('Doepke'), 'D450')
        self.assertEqual(self.pa.encode('Divish'), 'D450')
        self.assertEqual(self.pa.encode('Dobosh'), 'D450')
        self.assertEqual(self.pa.encode('Dupois'), 'D450')
        self.assertEqual(self.pa.encode('Dufek'), 'D450')
        self.assertEqual(self.pa.encode('Duffek'), 'D450')
        self.assertEqual(self.pa.encode('Dupuis'), 'D450')
        self.assertEqual(self.pa.encode('Dupas'), 'D450')
        self.assertEqual(self.pa.encode('Devese'), 'D450')
        self.assertEqual(self.pa.encode('Devos'), 'D450')
        self.assertEqual(self.pa.encode('Deveaux'), 'D450')
        self.assertEqual(self.pa.encode('Devies'), 'D450')

        self.assertEqual(self.pa.encode('Sand'), 'S210')
        self.assertEqual(self.pa.encode('Sandau'), 'S210')
        self.assertEqual(self.pa.encode('Sande'), 'S210')
        self.assertEqual(self.pa.encode('Sandia'), 'S210')
        self.assertEqual(self.pa.encode('Sando'), 'S210')
        self.assertEqual(self.pa.encode('Sandoe'), 'S210')
        self.assertEqual(self.pa.encode('Sandy'), 'S210')
        self.assertEqual(self.pa.encode('Santee'), 'S210')
        self.assertEqual(self.pa.encode('Santi'), 'S210')
        self.assertEqual(self.pa.encode('Santo'), 'S210')
        self.assertEqual(self.pa.encode('Send'), 'S210')
        self.assertEqual(self.pa.encode('Sennet'), 'S210')
        self.assertEqual(self.pa.encode('Shemoit'), 'S210')
        self.assertEqual(self.pa.encode('Shenot'), 'S210')
        self.assertEqual(self.pa.encode('Shumate'), 'S210')
        self.assertEqual(self.pa.encode('Simmet'), 'S210')
        self.assertEqual(self.pa.encode('Simot'), 'S210')
        self.assertEqual(self.pa.encode('Sineath'), 'S210')
        self.assertEqual(self.pa.encode('Sinnott'), 'S210')
        self.assertEqual(self.pa.encode('Sintay'), 'S210')
        self.assertEqual(self.pa.encode('Smead'), 'S210')
        self.assertEqual(self.pa.encode('Smeda'), 'S210')
        self.assertEqual(self.pa.encode('Smit'), 'S210')

        # Additional tests from @Yomguithereal's talisman
        # https://github.com/Yomguithereal/talisman/blob/master/test/phonetics/lein.js
        self.assertEqual(self.pa.encode('Guillaume'), 'G320')
        self.assertEqual(self.pa.encode('Arlène'), 'A332')
        self.assertEqual(self.pa.encode('Lüdenscheidt'), 'L125')

        # Coverage
        self.assertEqual(self.pa_n0.encode('Lüdenscheidt'), 'L125')
        self.assertEqual(self.pa_n0.encode('Smith'), 'S21')

        # encode_alpha
        self.assertEqual(self.pa.encode_alpha('Deveaux'), 'DPK')
        self.assertEqual(self.pa.encode_alpha('Devies'), 'DPK')
        self.assertEqual(self.pa.encode_alpha('Sand'), 'SNT')
        self.assertEqual(self.pa.encode_alpha('Sandau'), 'SNT')

        # Test wrapper
        self.assertEqual(lein('Dubose'), 'D450')
Ejemplo n.º 3
0
 lambda _: ', '.join(haase.encode(_)),
 'haase_phonetik_primary':
 lambda _: haase_primary.encode(_)[0],
 'henry_early':
 HenryEarly().encode,
 'henry_early_ml8':
 HenryEarly(max_length=8).encode,
 'koelner_phonetik':
 koelner.encode,
 'koelner_phonetik_num_to_alpha': (
     lambda _: koelner._to_alpha(koelner.encode(_))  # noqa: SF01
 ),
 'koelner_phonetik_alpha':
 koelner.encode_alpha,
 'lein':
 LEIN().encode,
 'lein_nopad_ml8':
 LEIN(max_length=8, zero_pad=False).encode,
 'metasoundex':
 MetaSoundex().encode,
 'metasoundex_es':
 MetaSoundex(lang='es').encode,
 'metaphone':
 Metaphone().encode,
 'mra':
 MRA().encode,
 'norphone':
 Norphone().encode,
 'nrl':
 NRL().encode,
 'nysiis':