Esempio n. 1
0
 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'])
Esempio n. 2
0
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'
     ])
Esempio n. 5
0
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
Esempio n. 6
0
 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
Esempio n. 7
0
 def testSuggestionsNone(self):
     helper = LanguageHelper(sample)
     self.assertEqual(helper.getSuggestions('blech'), [])
Esempio n. 8
0
 def testSugeestionsCapitalization(self):
     helper = LanguageHelper(sample)
     self.assertEqual(helper.getSuggestions('Gate'),
                      ['Cate', 'Date', 'Grate'])
Esempio n. 9
0
 def testSugeestionsMany(self):
     helper = LanguageHelper(rhymesWithDog)
     self.assertEqual(helper.getSuggestions('rog'),
                      ['bog', 'cog', 'fog', 'frog', 'hog', 'log'])
Esempio n. 10
0
 def testSuggestDeletion(self):
     helper = LanguageHelper(sample)
     self.assertEqual(helper.getSuggestions('gratle'), ['grate'])
Esempio n. 11
0
 def setUp(self):
     self.test = LanguageHelper(language)
Esempio n. 12
0
 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'])
Esempio n. 15
0
 def setUp(self):
     self.help = LanguageHelper(lexicon)
Esempio n. 16
0
 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
Esempio n. 17
0
 def testSingleLetterWords(self):
     helper = LanguageHelper(singleLetter)
     self.assertEqual(
         helper.getSuggestions('B'), []
     )  #Cannot correct a single letter misspelling, Microsoft Word spell-checker does not
Esempio n. 18
0
 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
Esempio n. 19
0
 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
Esempio n. 20
0
 def testSuggestInsertion(self):
     helper = LanguageHelper(sample)
     self.assertEqual(helper.getSuggestions('pikle'), ['pickle'])
     self.assertEqual(helper.getSuggestions('ct'), ['cat', 'cot'])