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)])
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)])
def testFindErrors_02(self): self._copyDict('ru_RU') checker = SpellChecker(['ru_RU'], [self._pathToDicts]) checker.skipWordsWithNumbers = True errors = checker.findErrors(' проверка ') self.assertEqual(errors, [])
def testEn_02(self): self._copyDict('en_US') checker = SpellChecker(['en_US'], [self._pathToDicts]) checker.skipWordsWithNumbers = True errors = checker.findErrors(' test ') self.assertEqual(errors, [])
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
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"])
def testEmpty_02(self): checker = SpellChecker([], []) self.assertTrue(checker.check('ывпаывапыв'))
def testInvalid_01(self): self._copyDictFrom('en-US-абырвалг', '../test/spell') SpellChecker(['en-US-абырвалг'], [self._pathToDicts])
def testRu_yo_01(self): self._copyDict('ru_YO') checker = SpellChecker(['ru_YO'], [self._pathToDicts]) self.assertTrue(checker.check('ёж'))
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))
def testNumbers_02(self): self._copyDict('ru_RU') checker = SpellChecker(['ru_RU'], [self._pathToDicts]) checker.skipWordsWithNumbers = False self.assertFalse(checker.check('ыяаывфафыа123'))
def testEn_01(self): self._copyDict('en_US') checker = SpellChecker(['en_US'], [self._pathToDicts]) self.assertTrue(checker.check('test')) self.assertFalse(checker.check('asdfasfffadsf'))
def testRu_01(self): self._copyDict('ru_RU') checker = SpellChecker(['ru_RU'], [self._pathToDicts]) self.assertTrue(checker.check('Проверка')) self.assertFalse(checker.check('ывпывапыяа'))
def testEmpty_03(self): checker = SpellChecker([], [self._pathToDicts]) self.assertTrue(checker.check('ывпаывапыв'))
def testFindErrors_07(self): checker = SpellChecker(['ru_RU'], ['spell']) checker.skipWordsWithNumbers = True errors = checker.findErrors(' проверка ') self.assertEqual(errors, [])
def testEmpty_01(self): self._copyDict('ru_RU') checker = SpellChecker(['ru_RU'], []) self.assertTrue(checker.check('ывпаывапыв'))