示例#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)])
示例#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)])
示例#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, [])
示例#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, [])
示例#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
示例#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
示例#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"])
示例#8
0
 def testEmpty_02(self):
     checker = SpellChecker([], [])
     self.assertTrue(checker.check('ывпаывапыв'))
示例#9
0
 def testInvalid_01(self):
     self._copyDictFrom('en-US-абырвалг', '../test/spell')
     SpellChecker(['en-US-абырвалг'], [self._pathToDicts])
示例#10
0
 def testRu_yo_01(self):
     self._copyDict('ru_YO')
     checker = SpellChecker(['ru_YO'], [self._pathToDicts])
     self.assertTrue(checker.check('ёж'))
示例#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))
示例#12
0
 def testNumbers_02(self):
     self._copyDict('ru_RU')
     checker = SpellChecker(['ru_RU'], [self._pathToDicts])
     checker.skipWordsWithNumbers = False
     self.assertFalse(checker.check('ыяаывфафыа123'))
示例#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'))
示例#14
0
 def testRu_01(self):
     self._copyDict('ru_RU')
     checker = SpellChecker(['ru_RU'], [self._pathToDicts])
     self.assertTrue(checker.check('Проверка'))
     self.assertFalse(checker.check('ывпывапыяа'))
示例#15
0
 def testEmpty_03(self):
     checker = SpellChecker([], [self._pathToDicts])
     self.assertTrue(checker.check('ывпаывапыв'))
示例#16
0
    def testFindErrors_07(self):
        checker = SpellChecker(['ru_RU'], ['spell'])
        checker.skipWordsWithNumbers = True

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