Ejemplo n.º 1
0
    def test_adding_unicode(self):
        ''' test adding a unicode word to the dictionary '''
        spell = SpellChecker()
        spell.word_frequency.load_words(['mañana'])
        self.assertEqual('ñ' in spell.word_frequency.letters, True)

        here = os.path.dirname(__file__)
        new_filepath = '{}/resources/small_dictionary_new.json.gz'.format(here)
        spell.export(new_filepath, gzipped=True)

        spell2 = SpellChecker(language=None, local_dictionary=new_filepath)
        self.assertEqual("mañana" in spell2, True)

        os.remove(new_filepath)
Ejemplo n.º 2
0
    def test_import_export_gzip(self):
        ''' test the export functionality as gzip '''
        here = os.path.dirname(__file__)
        filepath = '{}/resources/small_dictionary.json'.format(here)

        spell = SpellChecker(language=None, local_dictionary=filepath)
        spell.word_frequency.add('meh')
        new_filepath = '{}/resources/small_dictionary_new.json.gz'.format(here)
        spell.export(new_filepath, gzipped=True)

        sp = SpellChecker(language=None, local_dictionary=new_filepath)
        self.assertTrue('meh' in sp)
        self.assertFalse('bananna' in sp)

        os.remove(new_filepath)
Ejemplo n.º 3
0
from spellchecker import SpellChecker

spell = SpellChecker(language=None, case_sensitive=False)

spell.word_frequency.load_text_file('hincorpus.txt', encoding='utf-8')

spell.export('my_hin.gz', gzipped=True)