class SPFCTestCases(unittest.TestCase): """Test SPFC functions. test cases for abydos.phonetic.SPFC """ pa = SPFC() def test_spfc(self): """Test abydos.phonetic.SPFC.""" self.assertEqual(self.pa.encode(''), '') # https://archive.org/stream/accessingindivid00moor#page/19/mode/1up self.assertEqual(self.pa.encode(('J', 'KUHNS')), '16760') self.assertEqual(self.pa.encode(('G', 'ALTSHULER')), '35797') self.assertEqual(self.pa.encode('J KUHNS'), '16760') self.assertEqual(self.pa.encode('G ALTSHULER'), '35797') self.assertEqual(self.pa.encode('J. KUHNS'), '16760') self.assertEqual(self.pa.encode('G. ALTSHULER'), '35797') self.assertEqual(self.pa.encode('J. Kuhns'), '16760') self.assertEqual(self.pa.encode('G. Altshuler'), '35797') self.assertEqual(self.pa.encode('T. Vines'), '16760') self.assertEqual(self.pa.encode('J. Butler'), '35779') self.assertNotEqual(self.pa.encode('J. Kuhns'), self.pa.encode('J. Kuntz')) self.assertEqual(self.pa.encode('Jon Kuhns'), '16760') self.assertEqual(self.pa.encode('James Kuhns'), '16760') self.assertRaises(AttributeError, self.pa.encode, ('J', 'A', 'Kuhns')) self.assertRaises(AttributeError, self.pa.encode, 'JKuhns') self.assertRaises(AttributeError, self.pa.encode, 5) # etc. (for code coverage) self.assertEqual(self.pa.encode('James Goldstein'), '77795') self.assertEqual(self.pa.encode('James Hansen'), '57760') self.assertEqual(self.pa.encode('James Hester'), '57700') self.assertEqual(self.pa.encode('James Bardot'), '31745') self.assertEqual(self.pa.encode('James Windsor'), '27765') self.assertEqual(self.pa.encode('James Wenders'), '27760') self.assertEqual(self.pa.encode('James Ventor'), '17760') self.assertEqual(self.pa.encode('þ þ'), '00') # encode_alpha self.assertEqual(self.pa.encode_alpha('J. Kuhns'), 'CSGMS') self.assertEqual(self.pa.encode_alpha('G. Altshuler'), 'ARGEG') self.assertEqual(self.pa.encode_alpha('T. Vines'), 'CSGMS') self.assertEqual(self.pa.encode_alpha('James Ventor'), 'CZGMS') # Test wrapper self.assertEqual(spfc('G ALTSHULER'), '35797')
RethSchek, RogerRoot, RussellIndex, SPFC, SfinxBis, SoundD, Soundex, SoundexBR, SpanishMetaphone, StatisticsCanada, Waahlin, ) from . import EXTREME_TEST, _corpus_file, _fuzz, _random_char spfc = SPFC() algorithms = { 'ainsworth': Ainsworth().encode, 'alpha_sis': AlphaSIS().encode, 'bmpm': BeiderMorse().encode, 'bmpm_german': BeiderMorse(language_arg='german').encode, 'bmpm_french': BeiderMorse(language_arg='french').encode, 'bmpm_gen_exact': BeiderMorse(match_mode='exact').encode, 'bmpm_ash_approx': BeiderMorse(name_mode='ash').encode, 'bmpm_ash_exact': BeiderMorse(name_mode='ash', match_mode='exact').encode, 'bmpm_sep_approx': BeiderMorse(name_mode='sep').encode, 'bmpm_sep_exact': BeiderMorse(name_mode='sep', match_mode='exact').encode, 'caverphone_1': Caverphone(version=1).encode, 'caverphone_2': Caverphone().encode, 'daitch_mokotoff_soundex': DaitchMokotoff().encode,
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': BeiderMorse(language_arg='french').encode, 'bmpm_gen_exact': BeiderMorse(match_mode='exact').encode, 'bmpm_ash_approx':
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, 'refined_soundex_vowels': RefinedSoundex(retain_vowels=True).encode, 'refined_soundex_0pad_ml6': RefinedSoundex(