class PhoneticTestCases(unittest.TestCase):
    """Test phonetic fingerprint functions.

    abydos.fingerprint.Phonetic
    """

    fp = Phonetic()
    fp_phonet = Phonetic(Phonet())
    fp_soundex = Phonetic(Soundex())
    soundex = Soundex()

    def test_phonetic_fingerprint(self):
        """Test abydos.fingerprint.Phonetic."""
        # Base case
        self.assertEqual(self.fp.fingerprint(''), '')

        self.assertEqual(
            self.fp.fingerprint(' '.join(NIALL)), 'a anl mknl njl nklk nl'
        )
        self.assertEqual(
            self.fp_phonet.fingerprint(' '.join(NIALL)),
            'knile makneil maknele neil nel nele nial nigeli '
            + 'nigl nil noigialach oneil ui',
        )
        self.assertEqual(
            self.fp_soundex.fingerprint(' '.join(NIALL)),
            'k540 m254 n240 n242 n400 o540 u000',
        )
Beispiel #2
0
    'consonant_2': Consonant(variant=2).fingerprint,
    'consonant_3': Consonant(variant=3).fingerprint,
    'consonant_nd': Consonant(doubles=False).fingerprint,
    'count': Count().fingerprint,
    'count_32': Count(n_bits=32).fingerprint,
    'extract': Extract().fingerprint,
    'extract_2': Extract(letter_list=2).fingerprint,
    'extract_3': Extract(letter_list=3).fingerprint,
    'extract_4': Extract(letter_list=4).fingerprint,
    'extract_position_frequency': ExtractPositionFrequency().fingerprint,
    'lacss': LACSS().fingerprint,
    'lc_cutter': LCCutter().fingerprint,
    'occurrence': Occurrence().fingerprint,
    'occurrence_halved': OccurrenceHalved().fingerprint,
    'omission_key': OmissionKey().fingerprint,
    'phonetic': Phonetic().fingerprint,
    'position': Position().fingerprint,
    'position_32_2': Position(n_bits=32, bits_per_letter=2).fingerprint,
    'qgram': QGram().fingerprint,
    'qgram_q3': QGram(qval=3).fingerprint,
    'qgram_ssj': QGram(start_stop='$#', joiner=' ').fingerprint,
    'skeleton_key': SkeletonKey().fingerprint,
    'string': String().fingerprint,
    'synoname_toolcode': synoname.fingerprint,
    'synoname_toolcode_2name': lambda _: synoname.fingerprint(_, _),
}


class BigListOfNaughtyStringsTestCases(unittest.TestCase):
    """Test each fingerprint algorithm against the BLNS set.
    QGram,
    SkeletonKey,
    String,
    SynonameToolcode,
)

from . import EXTREME_TEST, _corpus_file, _fuzz, _random_char

synoname = SynonameToolcode()

algorithms = {
    'str_fingerprint': String().fingerprint,
    'qgram_fingerprint': QGram().fingerprint,
    'qgram_fingerprint_3': QGram(qval=3).fingerprint,
    'qgram_fingerprint_ssj': QGram(start_stop='$#', joiner=' ').fingerprint,
    'phonetic_fingerprint': Phonetic().fingerprint,
    'skeleton_key': SkeletonKey().fingerprint,
    'omission_key': OmissionKey().fingerprint,
    'occurrence_fingerprint': Occurrence().fingerprint,
    'occurrence_halved_fingerprint': OccurrenceHalved().fingerprint,
    'count_fingerprint': Count().fingerprint,
    'position_fingerprint': Position().fingerprint,
    'synoname_toolcode': synoname.fingerprint,
    'synoname_toolcode_2name': lambda _: synoname.fingerprint(_, _),
}


class BigListOfNaughtyStringsTestCases(unittest.TestCase):
    """Test each fingerprint algorithm against the BLNS set.

    Here, we test each algorithm against each string, but we only care that it
Beispiel #4
0
    Occurrence,
    OccurrenceHalved,
    OmissionKey,
    Phonetic,
    Position,
    QGram,
    SkeletonKey,
    String,
    SynonameToolcode,
)

from . import EXTREME_TEST, _corpus_file, _fuzz, _random_char

string = String()
qgram = QGram()
phonetic = Phonetic()
skeleton = SkeletonKey()
omission = OmissionKey()
occurrence = Occurrence()
occurrence_halved = OccurrenceHalved()
count = Count()
position = Position()
synoname = SynonameToolcode()

algorithms = {
    'str_fingerprint':
    string.fingerprint,
    'qgram_fingerprint':
    qgram.fingerprint,
    'qgram_fingerprint_3':
    lambda _: qgram.fingerprint(_, qval=3),