class RussellIndexTestCases(unittest.TestCase): """Test Russel Index functions. test cases for abydos.RussellIndex """ pa = RussellIndex() def test_russel_index(self): """Test abydos.phonetic.RussellIndex.""" self.assertTrue(math.isnan(self.pa.encode(''))) self.assertTrue(math.isnan(self.pa.encode('H'))) self.assertEqual(self.pa.encode('Hoppa'), 12) self.assertEqual(self.pa.encode('Hopley'), 125) self.assertEqual(self.pa.encode('Highfield'), 1254) self.assertEqual(self.pa.encode('Wright'), 814) self.assertEqual(self.pa.encode('Carter'), 31848) self.assertEqual(self.pa.encode('Hopf'), 12) self.assertEqual(self.pa.encode('Hay'), 1) self.assertEqual(self.pa.encode('Haas'), 1) self.assertEqual(self.pa.encode('Meyers'), 618) self.assertEqual(self.pa.encode('Myers'), 618) self.assertEqual(self.pa.encode('Meyer'), 618) self.assertEqual(self.pa.encode('Myer'), 618) self.assertEqual(self.pa.encode('Mack'), 613) self.assertEqual(self.pa.encode('Knack'), 3713) def test_russel_index_alpha(self): """Test abydos.phonetic.RussellIndex.encode_alpha.""" self.assertEqual(self.pa.encode_alpha(''), '') self.assertEqual(self.pa.encode_alpha('H'), '') self.assertEqual(self.pa.encode_alpha('Hoppa'), 'AB') self.assertEqual(self.pa.encode_alpha('Hopley'), 'ABL') self.assertEqual(self.pa.encode_alpha('Highfield'), 'ABLD') self.assertEqual(self.pa.encode_alpha('Wright'), 'RAD') self.assertEqual(self.pa.encode_alpha('Carter'), 'CARDR') self.assertEqual(self.pa.encode_alpha('Hopf'), 'AB') self.assertEqual(self.pa.encode_alpha('Hay'), 'A') self.assertEqual(self.pa.encode_alpha('Haas'), 'A') self.assertEqual(self.pa.encode_alpha('Meyers'), 'MAR') self.assertEqual(self.pa.encode_alpha('Myers'), 'MAR') self.assertEqual(self.pa.encode_alpha('Meyer'), 'MAR') self.assertEqual(self.pa.encode_alpha('Myer'), 'MAR') self.assertEqual(self.pa.encode_alpha('Mack'), 'MAC') self.assertEqual(self.pa.encode_alpha('Knack'), 'CNAC')
class RussellIndexTestCases(unittest.TestCase): """Test Russel Index functions. test cases for abydos.RussellIndex """ pa = RussellIndex() def test_russel_index(self): """Test abydos.phonetic.RussellIndex.""" self.assertEqual(self.pa.encode(''), '') self.assertEqual(self.pa.encode('H'), '') self.assertEqual(self.pa.encode('Hoppa'), '12') self.assertEqual(self.pa.encode('Hopley'), '125') self.assertEqual(self.pa.encode('Highfield'), '1254') self.assertEqual(self.pa.encode('Wright'), '814') self.assertEqual(self.pa.encode('Carter'), '31848') self.assertEqual(self.pa.encode('Hopf'), '12') self.assertEqual(self.pa.encode('Hay'), '1') self.assertEqual(self.pa.encode('Haas'), '1') self.assertEqual(self.pa.encode('Meyers'), '618') self.assertEqual(self.pa.encode('Myers'), '618') self.assertEqual(self.pa.encode('Meyer'), '618') self.assertEqual(self.pa.encode('Myer'), '618') self.assertEqual(self.pa.encode('Mack'), '613') self.assertEqual(self.pa.encode('Knack'), '3713') def test_russel_index_alpha(self): """Test abydos.phonetic.RussellIndex.encode_alpha.""" self.assertEqual(self.pa.encode_alpha(''), '') self.assertEqual(self.pa.encode_alpha('H'), '') self.assertEqual(self.pa.encode_alpha('Hoppa'), 'AB') self.assertEqual(self.pa.encode_alpha('Hopley'), 'ABL') self.assertEqual(self.pa.encode_alpha('Highfield'), 'ABLD') self.assertEqual(self.pa.encode_alpha('Wright'), 'RAD') self.assertEqual(self.pa.encode_alpha('Carter'), 'CARDR') self.assertEqual(self.pa.encode_alpha('Hopf'), 'AB') self.assertEqual(self.pa.encode_alpha('Hay'), 'A') self.assertEqual(self.pa.encode_alpha('Haas'), 'A') self.assertEqual(self.pa.encode_alpha('Meyers'), 'MAR') self.assertEqual(self.pa.encode_alpha('Myers'), 'MAR') self.assertEqual(self.pa.encode_alpha('Meyer'), 'MAR') self.assertEqual(self.pa.encode_alpha('Myer'), 'MAR') self.assertEqual(self.pa.encode_alpha('Mack'), 'MAC') self.assertEqual(self.pa.encode_alpha('Knack'), 'CNAC')
class RussellIndexTestCases(unittest.TestCase): """Test Russel Index functions. test cases for abydos.RussellIndex """ pa = RussellIndex() def test_russel_index(self): """Test abydos.phonetic.RussellIndex.""" self.assertTrue(math.isnan(self.pa.encode(''))) self.assertTrue(math.isnan(self.pa.encode('H'))) self.assertEqual(self.pa.encode('Hoppa'), 12) self.assertEqual(self.pa.encode('Hopley'), 125) self.assertEqual(self.pa.encode('Highfield'), 1254) self.assertEqual(self.pa.encode('Wright'), 814) self.assertEqual(self.pa.encode('Carter'), 31848) self.assertEqual(self.pa.encode('Hopf'), 12) self.assertEqual(self.pa.encode('Hay'), 1) self.assertEqual(self.pa.encode('Haas'), 1) self.assertEqual(self.pa.encode('Meyers'), 618) self.assertEqual(self.pa.encode('Myers'), 618) self.assertEqual(self.pa.encode('Meyer'), 618) self.assertEqual(self.pa.encode('Myer'), 618) self.assertEqual(self.pa.encode('Mack'), 613) self.assertEqual(self.pa.encode('Knack'), 3713) # Test wrapper self.assertEqual(russell_index('Highfield'), 1254) def test_russel_index_n2a(self): """Test abydos.phonetic.RussellIndex._to_alpha.""" self.assertEqual(self.pa._to_alpha(0), '') # noqa: SF01 self.assertEqual(self.pa._to_alpha(''), '') # noqa: SF01 self.assertEqual(self.pa._to_alpha(float('NaN')), '') # noqa: SF01 self.assertEqual( self.pa._to_alpha(123456789), 'ABCDLMNR' # noqa: SF01 ) self.assertEqual( self.pa._to_alpha('0123456789'), 'ABCDLMNR' # noqa: SF01 ) # Test wrapper self.assertEqual(russell_index_num_to_alpha(123456789), 'ABCDLMNR') def test_russel_index_alpha(self): """Test abydos.phonetic.RussellIndex.encode_alpha.""" self.assertEqual(self.pa.encode_alpha(''), '') self.assertEqual(self.pa.encode_alpha('H'), '') self.assertEqual(self.pa.encode_alpha('Hoppa'), 'AB') self.assertEqual(self.pa.encode_alpha('Hopley'), 'ABL') self.assertEqual(self.pa.encode_alpha('Highfield'), 'ABLD') self.assertEqual(self.pa.encode_alpha('Wright'), 'RAD') self.assertEqual(self.pa.encode_alpha('Carter'), 'CARDR') self.assertEqual(self.pa.encode_alpha('Hopf'), 'AB') self.assertEqual(self.pa.encode_alpha('Hay'), 'A') self.assertEqual(self.pa.encode_alpha('Haas'), 'A') self.assertEqual(self.pa.encode_alpha('Meyers'), 'MAR') self.assertEqual(self.pa.encode_alpha('Myers'), 'MAR') self.assertEqual(self.pa.encode_alpha('Meyer'), 'MAR') self.assertEqual(self.pa.encode_alpha('Myer'), 'MAR') self.assertEqual(self.pa.encode_alpha('Mack'), 'MAC') self.assertEqual(self.pa.encode_alpha('Knack'), 'CNAC') # Test wrapper self.assertEqual(russell_index_alpha('Highfield'), 'ABLD')
'phonix': Phonix().encode, 'phonix_0pad_ml6': Phonix(max_length=6, zero_pad=True).encode, 'pshp_soundex_first': PSHPSoundexFirst().encode, 'pshp_soundex_first_german': PSHPSoundexFirst(german=True).encode, 'pshp_soundex_first_ml8': PSHPSoundexFirst(max_length=8).encode, 'pshp_soundex_last': PSHPSoundexLast().encode, 'pshp_soundex_last_german': PSHPSoundexLast(german=True).encode, 'pshp_soundex_last_ml8': PSHPSoundexLast(max_length=8).encode, 'refined_soundex': RefinedSoundex().encode, 'refined_soundex_vowels': RefinedSoundex(retain_vowels=True).encode, 'refined_soundex_0pad_ml6': RefinedSoundex(zero_pad=True, max_length=6).encode, 'reth_schek_phonetik': RethSchek().encode, 'roger_root': RogerRoot().encode, 'roger_root_nopad_ml8': RogerRoot(max_length=8, zero_pad=False).encode, 'russell_index': RussellIndex().encode, 'russell_index_alpha': RussellIndex().encode_alpha, 'sfinxbis': SfinxBis().encode, 'sfinxbis_ml6': SfinxBis(max_length=6).encode, 'sound_d': SoundD().encode, 'sound_d_ml8': SoundD(max_length=8).encode, 'soundex': Soundex().encode, 'soundex_reverse': Soundex(reverse=True).encode, 'soundex_0pad_ml6': Soundex(zero_pad=True, max_length=6).encode, 'soundex_special': Soundex(var='special').encode, 'soundex_census': Soundex(var='Census').encode, 'soundex_br': SoundexBR().encode, 'spanish_metaphone': SpanishMetaphone().encode, 'spanish_metaphone_modified': SpanishMetaphone(modified=True).encode, 'spanish_metaphone_ml4': SpanishMetaphone(max_length=4).encode, 'spfc': lambda _: spfc.encode('{0} {0}'.format(_)),
Soundex, SoundexBR, SpanishMetaphone, StatisticsCanada, Waahlin, ) from . import EXTREME_TEST, _corpus_file, _fuzz, _random_char alpha_sis = AlphaSIS() daitch_mokotoff = DaitchMokotoff() double_metaphone = DoubleMetaphone() haase = Haase() haase_primary = Haase(primary_only=True) koelner = Koelner() russell = RussellIndex() sfinxbis = SfinxBis() sfinxbis_6 = SfinxBis(max_length=6) soundex_census = Soundex(var='Census') spfc = SPFC() algorithms = { 'ainsworth': Ainsworth().encode, 'alpha_sis': lambda _: ', '.join(alpha_sis.encode(_)), 'bmpm': BeiderMorse().encode, 'bmpm_german': BeiderMorse(language_arg='german').encode, 'bmpm_french':
RefinedSoundex, RethSchek, RogerRoot, RussellIndex, SPFC, SfinxBis, SoundD, Soundex, SoundexBR, SpanishMetaphone, StatisticsCanada, ) from . import EXTREME_TEST, _corpus_file, _fuzz, _random_char russell = RussellIndex() koelner = Koelner() spfc = SPFC() algorithms = { 'russell_index': russell.encode, 'russell_index_num_to_alpha': lambda _: russell._to_alpha( # noqa: SF01 russell.encode(_) ), 'russell_index_alpha': russell.encode_alpha, 'soundex': Soundex().encode, 'reverse_soundex': Soundex(reverse=True).encode, 'soundex_0pad_ml6': Soundex(zero_pad=True, max_length=6).encode, 'soundex_special': Soundex(var='special').encode, 'soundex_census': Soundex(var='Census').encode, 'refined_soundex': RefinedSoundex().encode,
norphone = Norphone() nrl = NRL() nysiis = NYSIIS() onca = ONCA() parmar_kumbharana = ParmarKumbharana() phonem = Phonem() phonet = Phonet() phonetic_spanish = PhoneticSpanish() phonex = Phonex() phonix = Phonix() pshp_soundex_first = PSHPSoundexFirst() pshp_soundex_last = PSHPSoundexLast() refined_soundex = RefinedSoundex() reth_schek = RethSchek() roger_root = RogerRoot() russell = RussellIndex() sfinxbis = SfinxBis() sound_d = SoundD() soundex = Soundex() soundex_br = SoundexBR() spanish_metaphone = SpanishMetaphone() spfc = SPFC() statistics_canada = StatisticsCanada() algorithms = { 'russell_index': lambda _: str(russell.encode(_)), 'russell_index_num_to_alpha': lambda _: russell._to_alpha( # noqa: SF01 russell.encode(_)), 'russell_index_alpha':