Exemplo n.º 1
0
    def testFindErrors_06(self):
        self._copyDict('ru_RU')
        checker = SpellChecker(['ru_RU'], [self._pathToDicts])
        checker.skipWordsWithNumbers = True

        errors = checker.findErrors('проверка ййй ээээ тест')
        self.assertEqual(errors, [('ййй', 9, 12), ('ээээ', 13, 17)])
Exemplo n.º 2
0
    def testFindErrors_05(self):
        self._copyDict('ru_RU')
        checker = SpellChecker(['ru_RU'], [self._pathToDicts])
        checker.skipWordsWithNumbers = False

        errors = checker.findErrors('ййй12')
        self.assertEqual(errors, [('ййй12', 0, 5)])
Exemplo n.º 3
0
    def testFindErrors_02(self):
        self._copyDict('ru_RU')
        checker = SpellChecker(['ru_RU'], [self._pathToDicts])
        checker.skipWordsWithNumbers = True

        errors = checker.findErrors('  проверка   ')
        self.assertEqual(errors, [])
Exemplo n.º 4
0
    def testEn_02(self):
        self._copyDict('en_US')
        checker = SpellChecker(['en_US'], [self._pathToDicts])
        checker.skipWordsWithNumbers = True

        errors = checker.findErrors('  test   ')
        self.assertEqual(errors, [])
Exemplo n.º 5
0
    def getSpellChecker(self):
        langlist = self._getDictsFromConfig()
        spellDirList = outwiker.core.system.getSpellDirList()

        spellChecker = SpellChecker(langlist, spellDirList)
        spellChecker.addCustomDict(os.path.join(spellDirList[-1], CUSTOM_DICT_FILE_NAME))

        return spellChecker
Exemplo n.º 6
0
    def getSpellChecker(self):
        langlist = self._getDictsFromConfig()
        spellDirList = outwiker.core.system.getSpellDirList()

        spellChecker = SpellChecker(langlist, spellDirList)
        spellChecker.addCustomDict(os.path.join(spellDirList[-1], CUSTOM_DICT_FILE_NAME))

        return spellChecker
Exemplo n.º 7
0
    def testRuEn_01(self):
        self._copyDict('ru_RU')
        self._copyDict('en_US')
        checker = SpellChecker(['ru_RU', 'en_US'], [self._pathToDicts])
        self.assertTrue(checker.check('Проверка'))
        self.assertTrue(checker.check('cat'))
        self.assertFalse(checker.check('ывпывапыяа'))
        self.assertFalse(checker.check('adfasdfasd'))

        finder = DictsFinder([self._pathToDicts])
        langs = sorted(finder.getLangList())

        self.assertEqual(langs, ["en_US", "ru_RU"])
Exemplo n.º 8
0
 def testEmpty_02(self):
     checker = SpellChecker([], [])
     self.assertTrue(checker.check('ывпаывапыв'))
Exemplo n.º 9
0
 def testInvalid_01(self):
     self._copyDictFrom('en-US-абырвалг', '../test/spell')
     SpellChecker(['en-US-абырвалг'], [self._pathToDicts])
Exemplo n.º 10
0
 def testRu_yo_01(self):
     self._copyDict('ru_YO')
     checker = SpellChecker(['ru_YO'], [self._pathToDicts])
     self.assertTrue(checker.check('ёж'))
Exemplo n.º 11
0
    def testUserDict_02(self):
        word = 'ывпывапыяа'
        dictname1 = 'mydict_1.dic'
        dictname2 = 'mydict_2.dic'

        self._copyDict('ru_RU')
        checker = SpellChecker(['ru_RU'], [self._pathToDicts])
        self.assertTrue(checker.check('Проверка'))
        self.assertFalse(checker.check(word))

        checker.addCustomDict(os.path.join(self._pathToDicts, dictname1))
        checker.addCustomDict(os.path.join(self._pathToDicts, dictname2))
        checker.addToCustomDict(1, word)
        self.assertTrue(checker.check(word))

        checker2 = SpellChecker(['ru_RU'], [self._pathToDicts])
        checker2.addCustomDict(os.path.join(self._pathToDicts, dictname1))
        self.assertFalse(checker2.check(word))

        checker3 = SpellChecker(['ru_RU'], [self._pathToDicts])
        checker3.addCustomDict(os.path.join(self._pathToDicts, dictname2))
        self.assertTrue(checker3.check(word))
Exemplo n.º 12
0
 def testNumbers_02(self):
     self._copyDict('ru_RU')
     checker = SpellChecker(['ru_RU'], [self._pathToDicts])
     checker.skipWordsWithNumbers = False
     self.assertFalse(checker.check('ыяаывфафыа123'))
Exemplo n.º 13
0
 def testEn_01(self):
     self._copyDict('en_US')
     checker = SpellChecker(['en_US'], [self._pathToDicts])
     self.assertTrue(checker.check('test'))
     self.assertFalse(checker.check('asdfasfffadsf'))
Exemplo n.º 14
0
 def testRu_01(self):
     self._copyDict('ru_RU')
     checker = SpellChecker(['ru_RU'], [self._pathToDicts])
     self.assertTrue(checker.check('Проверка'))
     self.assertFalse(checker.check('ывпывапыяа'))
Exemplo n.º 15
0
 def testEmpty_03(self):
     checker = SpellChecker([], [self._pathToDicts])
     self.assertTrue(checker.check('ывпаывапыв'))
Exemplo n.º 16
0
    def testFindErrors_07(self):
        checker = SpellChecker(['ru_RU'], ['spell'])
        checker.skipWordsWithNumbers = True

        errors = checker.findErrors('  проверка   ')
        self.assertEqual(errors, [])
Exemplo n.º 17
0
 def testEmpty_01(self):
     self._copyDict('ru_RU')
     checker = SpellChecker(['ru_RU'], [])
     self.assertTrue(checker.check('ывпаывапыв'))