Ejemplo 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'])
Ejemplo 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'
     ])
Ejemplo 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
Ejemplo 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
Ejemplo n.º 7
0
 def testSuggestionsNone(self):
     helper = LanguageHelper(sample)
     self.assertEqual(helper.getSuggestions('blech'), [])
Ejemplo n.º 8
0
 def testSugeestionsCapitalization(self):
     helper = LanguageHelper(sample)
     self.assertEqual(helper.getSuggestions('Gate'),
                      ['Cate', 'Date', 'Grate'])
Ejemplo n.º 9
0
 def testSugeestionsMany(self):
     helper = LanguageHelper(rhymesWithDog)
     self.assertEqual(helper.getSuggestions('rog'),
                      ['bog', 'cog', 'fog', 'frog', 'hog', 'log'])
Ejemplo n.º 10
0
 def testSuggestDeletion(self):
     helper = LanguageHelper(sample)
     self.assertEqual(helper.getSuggestions('gratle'), ['grate'])
Ejemplo n.º 11
0
 def setUp(self):
     self.test = LanguageHelper(language)
Ejemplo 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'])
Ejemplo n.º 15
0
 def setUp(self):
     self.help = LanguageHelper(lexicon)
Ejemplo 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
Ejemplo 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
Ejemplo 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
Ejemplo 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
Ejemplo n.º 20
0
 def testSuggestInsertion(self):
     helper = LanguageHelper(sample)
     self.assertEqual(helper.getSuggestions('pikle'), ['pickle'])
     self.assertEqual(helper.getSuggestions('ct'), ['cat', 'cot'])