Exemple #1
0
    def test_preprocess(self):
        s = 'rahcteictshtgihls'
        
        d, minlen, maxlen = mowords.buildDict('data/testmowords.txt')
        minlen = 4  # min length is 4 per requirement
        l = mowords.preprocess(d, s, minlen, maxlen)
        
        self.assertTrue('architect' in l[0])
        self.assertTrue('architects' in l[0])
        self.assertTrue('char' in l[0] or 'arch' in l[0])

        print "Lookup:", l
Exemple #2
0
 def test_minimizeSkip(self):
     s = 'rahcteictshtgihls'
     
     d, minlen, maxlen = mowords.buildDict('data/testmowords.txt')
     minlen = 4  # min length is 4 per requirement
     
     lookup = mowords.preprocess(d, s, minlen, maxlen)
     solutions = mowords.minimizeSkip(lookup, s)
     
     for i in range(0, len(solutions)):
         if i == 0 or i == 2 or i == 9 or i == 11:
             self.assertTrue(solutions[i] != None)
         
         if solutions[i] != None:                
             print 'Optimal solution for "', s[i:] , '"->', solutions[i].words, ', skips: ', solutions[i].skips
             
             
             
             
Exemple #3
0
 def test_buildDict(self):
     d, minlen, maxlen = mowords.buildDict('data/testmowords.txt')
     print 'Dictionary has',len(d.keys()),'keys'
     
     self.assertEqual(minlen, 4)
     self.assertEqual(maxlen, 16)
     self.assertEqual(10, len(d))
     self.assertTrue('achr' in d.keys())
     self.assertTrue('ghilst' in d.keys())
     self.assertTrue('aaaccehiinorrstt' in d.keys())
     
     v = d.get('achr')
     self.assertTrue('char' in v)
     self.assertTrue('arch' in v)       
     
     v = d.get('ghilst')
     self.assertTrue('slight' in v)
     self.assertTrue('lights' in v)
     
     v = d.get('aaaccehiinorrstt')
     self.assertTrue('characterisation' in v)