def test_load_spelling(self): config = FileStorageConfiguration() config._spelling_storage = FileStoreConfiguration(file=os.path.dirname(__file__) + os.sep + "data" + os.sep + "spelling" + os.sep + "corpus.txt", format="text", encoding="utf-8", delete_on_start=False) engine = FileStorageEngine(config) engine.initialise() store = FileSpellingStore(engine) store.empty() spelling_checker = NorvigSpellingChecker() store.load_spelling(spelling_checker) self.assertEqual("THESE ARE SOME WORDS", spelling_checker.correct("Thise ara sime wards"))
def test_load_spelling_with_exception(self): config = FileStorageConfiguration() config._spelling_storage = FileStoreConfiguration(file=os.path.dirname(__file__) + os.sep + "data" + os.sep + "spelling" + os.sep + "corpus.txt", fileformat="text", encoding="utf-8", delete_on_start=False) engine = FileStorageEngine(config) engine.initialise() store = FileSpellingStore(engine) spelling_checker = NorvigSpellingChecker() self.assertFalse(store.load_spelling(spelling_checker))