def testLongWord(self): helper = LanguageHelper(long) self.assertEqual( helper.getSuggestions('georgeous'), ['gorgeous' ]) #correcting longer words, more likely to be misspelled self.assertEqual(helper.getSuggestions('beautifl'), ['beautiful'])
class BasicTest(unittest.TestCase): def setUp(self): self.help = LanguageHelper(lexicon) # make sure that all the words in the lexicon are recognized def testContainment(self): for w in lexicon: self.assertTrue(w in self.help) def testFailures(self): self.assertFalse('cate' in self.help) # only allowed when capitalized self.assertFalse('fox' in self.help) # word is not there self.assertFalse('cofee' in self.help) # mis-spell word is not there def testSuggestInsertion(self): self.assertEqual(self.help.getSuggestions('pikle'), ['pickle']) self.assertEqual(self.help.getSuggestions('ct'), ['cat', 'cot']) def testSuggestDeletion(self): self.assertEqual(self.help.getSuggestions('gratle'), ['grate']) def testSuggestionsCapitalization(self): self.assertEqual(self.help.getSuggestions('Gate'), ['Cate', 'Date', 'Grate']) def testSuggestionsNone(self): self.assertEqual(self.help.getSuggestions('blech'), [])
def testSugeestionsCapitalization(self): helper = LanguageHelper(sample) self.assertEqual(helper.getSuggestions('Gate'), [ 'Agate', 'Ate', 'Bate', 'Cate', 'Date', 'Fate', 'Gabe', 'Grate', 'Hate', 'Kate', 'Late', 'Mate', 'Nate', 'Pate', 'Rate', 'Sate', 'Tate', 'Yate', 'gate' ]) self.assertEqual(helper.getSuggestions('missouri'), ['Missouri'])
def test_case_sensitvity(self): helper = LanguageHelper(sample) self.assertEqual(helper.getSuggestions('rome'), [ 'Rome', 'brome', 'come', 'crome', 'dome', 'drome', 'frome', 'home', 'krome', 'mome', 'nome', 'pome', 'rame', 'rime', 'robe', 'rode', 'roe', 'roke', 'role', 'rone', 'rope', 'rose', 'rote', 'roue', 'rove', 'ryme', 'some', 'tome' ]) self.assertEqual(helper.getSuggestions('soMe'), ['some']) self.assertEqual(helper.getSuggestions('SOME'), ['some']) self.assertEqual(helper.getSuggestions('Some'), [ 'Come', 'Dome', 'Home', 'Mome', 'Nome', 'Pome', 'Rome', 'Tome', 'some' ])
class MyTests(unittest.TestCase): def setUp(self): self.test = LanguageHelper(language) def testContainsCapitalization(self): self.assertTrue(self.test.__contains__( 'Ball')) # Should be true since ball is in langauge def testQueryInSuggestions(self): self.assertEqual( self.test.getSuggestions('ball'), ['ball', 'balls' ]) # the query should be included in suggestions list def testInvertedCharacters(self): self.assertEqual(self.test.getSuggestions('wierd'), ['weird', 'wired']) def testSuggestionCapitalization(self): self.assertEqual( self.test.getSuggestions('NaTO'), ['NATO']) # should capitalize one letter to get word in language self.assertEqual(self.test.getSuggestions('rome'), [ 'Rome' ]) # should capitalize first letter to get proper noun in language
def testMovieTitle(self): helper = LanguageHelper(sample) self.assertFalse( 'Rango' in helper) #Movie title should not be in language-too specific self.assertFalse('Pokemon' in helper) #Same as above
def testSuggestionsNone(self): helper = LanguageHelper(sample) self.assertEqual(helper.getSuggestions('blech'), [])
def testSugeestionsCapitalization(self): helper = LanguageHelper(sample) self.assertEqual(helper.getSuggestions('Gate'), ['Cate', 'Date', 'Grate'])
def testSugeestionsMany(self): helper = LanguageHelper(rhymesWithDog) self.assertEqual(helper.getSuggestions('rog'), ['bog', 'cog', 'fog', 'frog', 'hog', 'log'])
def testSuggestDeletion(self): helper = LanguageHelper(sample) self.assertEqual(helper.getSuggestions('gratle'), ['grate'])
def setUp(self): self.test = LanguageHelper(language)
def testContainment(self): helper = LanguageHelper(sample) for w in sample: self.assertTrue(w in helper)
def test_non_english_words(self): helper = LanguageHelper(sample) self.assertEqual(helper.getSuggestions('Kom'), [ 'Bom', 'Com', 'Dom', 'Hom', 'Kum', 'Mom', 'Nom', 'Pom', 'Rom', 'Tom', 'Yom' ])
def test_Swap_letters(self): helper = LanguageHelper(sample) self.assertEqual(helper.getSuggestions('wierd'), ['weird', 'wield', 'wird', 'wired'])
def setUp(self): self.help = LanguageHelper(lexicon)
def testKeyboardSmash(self): helper = LanguageHelper(sample) self.assertFalse( 'asdfadwhgkfads' in helper ) #Incomprehensible string, should not be in language and too far away from any word to be corrected
def testSingleLetterWords(self): helper = LanguageHelper(singleLetter) self.assertEqual( helper.getSuggestions('B'), [] ) #Cannot correct a single letter misspelling, Microsoft Word spell-checker does not
def testFailures(self): helper = LanguageHelper(sample) self.assertFalse('cate' in helper) # only allowed when capitalized self.assertFalse('fox' in helper) # word is not there self.assertFalse('cofee' in helper) # mis-spell word is not there
def testWordEnteredTwice(self): helper = LanguageHelper(sample) self.assertFalse( 'catcat' in helper ) #checker only corrects for one letter difference, 'catcat' is three letters away from a correct word
def testSuggestInsertion(self): helper = LanguageHelper(sample) self.assertEqual(helper.getSuggestions('pikle'), ['pickle']) self.assertEqual(helper.getSuggestions('ct'), ['cat', 'cot'])