Beispiel #1
0
 def test_candidates(self):
     """ test spell checker candidates """
     spell = EnSpell()
     spell.check_init()
     print(spell.word_freq_dict.get('ths'), spell.candidates('ths'))
     self.assertEqual(len(spell.candidates('ths')) > 0, True)
     self.assertEqual(spell.candidates('the'), {'the'})
     self.assertEqual(spell.candidates('hi'), {'hi'})
     # something that cannot exist... should return just the same element...
     self.assertEqual(''.join(spell.candidates('manasaeds')), 'manasaeds')
Beispiel #2
0
    def test_en_bug_correct2(self):
        """测试英文纠错bug"""
        spell = EnSpell()
        spell.check_init()
        print(spell.word_freq_dict.get('whould'))
        print(spell.candidates('whould'))

        a = spell.correct_word('whould')
        print(a)
        r = en_correct('contend proble poety adress whould niether  quaties')
        print(r)
        assert en_correct('whould')[0] == 'would'  # no error