1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#!/usr/bin/perl -w
use Test::More 'no_plan';
BEGIN { use_ok "Text::Metaphone"; }
my %test_phones = (
'recrudescence' => 'RKRTSNS',
'moist' => 'MST',
'Gutenberg' => 'KTNBRK',
'recridessence' => 'RKRTSNS',
'crapulance' => 'KRPLNS',
'cough' => 'KF',
'coffee' => 'KF',
'tchrist' => 'TKRST',
'Schwern' => 'XWRN',
'Schwartz' => 'XWRTS',
'Avulsion' => 'AFLXN',
'Aeon' => 'EN',
'Mushrooms' => 'MXRMS',
'Way' => 'W',
'What' => 'HT',
'Wierd' => 'WRT',
'' => '',
'picklehead'=> 'PKLHT',
# Caused a crash because phoned word == length of word revealing
# an off-by-one allocation mistake.
'nsxkgbsfdtp' => 'NSKSKKBSFTT',
# An X on the end can make the phoned word one larger than the original.
'jgVqiNdxNVLpVBxQBlxghDx' => 'JKFKNTKSNFLPFBKSKBLKSTKS',
'ax1x1x' => 'AKSKSKS'
);
foreach my $word (keys %test_phones) {
is Metaphone($word), $test_phones{$word}, "$word";
}
|