Esempio n. 1
0
    def test_storage_path(self):
        config = FileStorageConfiguration()
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileSpellingStore(engine)

        self.assertEquals('/tmp/spelling/corpus.txt', store._get_storage_path())
        self.assertIsInstance(store.get_storage(), FileStoreConfiguration)
Esempio n. 2
0
    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))
Esempio n. 3
0
    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", fileformat="text", encoding="utf-8", delete_on_start=False)
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileSpellingStore(engine)

        spelling_checker = NorvigSpellingChecker()
        self.assertTrue(store.load_spelling(spelling_checker))

        self.assertEqual("THESE ARE SOME WORDS", spelling_checker.correct("Thise ara sime wards"))
Esempio n. 4
0
 def spelling_store(self):
     return FileSpellingStore(self)
 def test_initialise(self):
     config = FileStorageConfiguration()
     engine = FileStorageEngine(config)
     engine.initialise()
     store = FileSpellingStore(engine)
     self.assertEqual(store.storage_engine, engine)