Esempio n. 1
0
def load_dataset(fileprefix):
    dataset_filename = "%s_dataset_dict.pck" % fileprefix
    global dataset_dict
    global text

    print "Loading dataset..."
    if exists(dataset_filename):
        print "    Reading dataset from %s..." % dataset_filename
        dataset_dict = unpickle(dataset_filename)
    else:
        print "    Computing dataset..."
        dataset_dict = {}
        for i in xrange(1, 11):
            item_size = substring_size(i)
            dataset_dict[i] = get_random_substring_list(\
                text, LIST_SIZE, item_size)
        print "    Writing dataset to %s..." % dataset_filename
        picklefy(dataset_filename, dataset_dict)
        print "    Done."
Esempio n. 2
0
 def test_substring_size_for_1_is_5(self):
     i = 1
     expected = 5
     computed = substring_size(i)
     self.assertEquals(computed, expected)
Esempio n. 3
0
 def test_substring_size_for_3_is_20(self):
     i = 3
     expected = 20
     computed = substring_size(i)
     self.assertEquals(computed, expected)
Esempio n. 4
0
 def test_substring_size_for_2_is_10(self):
     i = 2
     expected = 10
     computed = substring_size(i)
     self.assertEquals(computed, expected)
Esempio n. 5
0
 def test_substring_size_for_1_is_5(self):
     i = 1
     expected = 5
     computed = substring_size(i)
     self.assertEquals(computed, expected)
Esempio n. 6
0
 def test_substring_size_for_3_is_20(self):
     i = 3
     expected = 20
     computed = substring_size(i)
     self.assertEquals(computed, expected)
Esempio n. 7
0
 def test_substring_size_for_2_is_10(self):
     i = 2
     expected = 10
     computed = substring_size(i)
     self.assertEquals(computed, expected)