Example #1
0
 def setUp(self):
     self.korpus_file = res.korpus_file
     self.anno_file = res.anno_file
     self.test_korpus = Korpus("Test")
     self.test_korpus.insert_from_file(self.korpus_file)
     self.test_data = Data("test_data", self.test_korpus)
     self.test_data.add_anno(self.anno_file)
Example #2
0
class TestBodyAttribute(unittest.TestCase):
    def setUp(self):
        self.korpus_file = res.korpus_file
        self.anno_file = res.anno_file
        self.test_korpus = Korpus("Test")
        self.test_korpus.insert_from_file(self.korpus_file)
        self.test_data = Data("test_data", self.test_korpus)
        self.test_data.add_anno(self.anno_file)
Example #3
0
class TestBodyAttribute(unittest.TestCase):
    def setUp(self):
        self.korpus_file = res.korpus_file
        self.anno_file = res.anno_file
        self.test_korpus = Korpus("Test")
        self.test_korpus.insert_from_file(self.korpus_file)
        self.test_data = Data("test_data", self.test_korpus)
        self.test_data.add_anno(self.anno_file)
Example #4
0
 def setUp(self):
     self.korpus_file = res.korpus_file
     self.anno_file = res.anno_file
     self.test_korpus = Korpus("Test")
     self.test_korpus.insert_from_file(self.korpus_file)
     self.test_data = Data("test_data", self.test_korpus)
     self.test_data.add_anno(self.anno_file)
     self.test_data.attach_feature("bag_of_words")
Example #5
0
class TestBodyTextpair(unittest.TestCase):
    def setUp(self):
        self.korpus_file = res.korpus_file
        self.anno_file = res.anno_file
        self.test_korpus = Korpus("Test")
        self.test_korpus.insert_from_file(self.korpus_file)
        self.test_data = Data("test_data", self.test_korpus)
        self.test_data.add_anno(self.anno_file)
        self.test_data.attach_feature("tf_idf")
Example #6
0
class TestBodyModel(unittest.TestCase):
    def setUp(self):
        self.korpus_file = res.korpus_file
        self.anno_file = res.anno_file
        self.test_korpus = Korpus("Test")
        self.test_korpus.insert_from_file(self.korpus_file)
        self.test_data = Data("test_data", self.test_korpus)
        self.test_data.add_anno(self.anno_file)
        self.test_data.attach_feature_list(res.feature_list)
Example #7
0
class TestBodyTextpair(unittest.TestCase):
    def setUp(self):
        self.korpus_file = res.korpus_file
        self.anno_file = res.anno_file
        self.test_korpus = Korpus("Test")
        self.test_korpus.insert_from_file(self.korpus_file)
        self.test_data = Data("test_data", self.test_korpus)
        self.test_data.add_anno(self.anno_file)
        self.test_data.attach_feature("tf_idf")
Example #8
0
class TestBodyModel(unittest.TestCase):
    def setUp(self):
        self.korpus_file = res.korpus_file
        self.anno_file = res.anno_file
        self.test_korpus = Korpus("Test")
        self.test_korpus.insert_from_file(self.korpus_file)
        self.test_data = Data("test_data", self.test_korpus)
        self.test_data.add_anno(self.anno_file)
        self.test_data.attach_feature_list(res.feature_list)
Example #9
0
 def setUp(self):
     self.korpus_file = res.korpus_file
     self.anno_file = res.anno_file
     self.test_korpus = Korpus("Test")
     self.test_korpus.insert_from_file(self.korpus_file)
     self.test_data = Data("test_data", self.test_korpus)
     self.test_data.add_anno(self.anno_file)
Example #10
0
 def setUp(self):
     self.korpus_file = res.korpus_file
     self.anno_file = res.anno_file
     self.test_korpus = Korpus("Test")
     self.test_korpus.insert_from_file(self.korpus_file)
     self.test_data = Data("test_data", self.test_korpus)
     self.test_data.add_anno(self.anno_file)
     self.test_data.attach_feature("bag_of_words")
Example #11
0
    def setUp(self):
        test_name = self.shortDescription()
        super(DataTest, self).setUp()
        self.mock_obj = Data("test_data", self.test_korpus)
        self.mock_obj.add_anno(self.anno_file)

        if test_name == "Test routine add_anno() in Data":
            print "setting up for testing add_anno()"
            self.textpair_dic = res.textpair_dic

        elif test_name == "Test routine attach_feature() in Data":
            print "setting up for testing attach_feature()"
            self.feature_name = "bag_of_words"

        elif test_name == "Test routine attach_feature_list() in Data":
            print "setting up for testing attach_feature_list()"
            self.feature_list = res.feature_list
Example #12
0
    def setUp(self):
        test_name = self.shortDescription()
        super(DataTest, self).setUp()
        self.mock_obj = Data("test_data", self.test_korpus)
        self.mock_obj.add_anno(self.anno_file)

        if test_name == "Test routine add_anno() in Data":
            print "setting up for testing add_anno()"
            self.textpair_dic = res.textpair_dic

        elif test_name == "Test routine attach_feature() in Data":
            print "setting up for testing attach_feature()"
            self.feature_name = "bag_of_words"

        elif test_name == "Test routine attach_feature_list() in Data":
            print "setting up for testing attach_feature_list()"
            self.feature_list = res.feature_list
Example #13
0
class DataTest(TestBodyData):
    @classmethod
    def setUpClass(cls):
        print "###################### Begin Testing Data Class ######################" + "\n"

    @classmethod
    def tearDownClass(cls):
        print "\n" + "###################### End Testing Data Class ######################"

    def setUp(self):
        test_name = self.shortDescription()
        super(DataTest, self).setUp()
        self.mock_obj = Data("test_data", self.test_korpus)
        self.mock_obj.add_anno(self.anno_file)

        if test_name == "Test routine add_anno() in Data":
            print "setting up for testing add_anno()"
            self.textpair_dic = res.textpair_dic

        elif test_name == "Test routine attach_feature() in Data":
            print "setting up for testing attach_feature()"
            self.feature_name = "bag_of_words"

        elif test_name == "Test routine attach_feature_list() in Data":
            print "setting up for testing attach_feature_list()"
            self.feature_list = res.feature_list

    def tearDown(self):
        test_name = self.shortDescription()
        self.korpus_file = None
        self.anno_file = None
        self.test_korpus = None
        self.mock_obj = None

        if test_name == "Test routine add_anno() in Data":
            print "cleaning up for testing add_anno()"
            self.textpair_dic = None
            print "--------------------------------------------------------------"

        elif test_name == "Test routine attach_feature() in Data":
            print "cleaning up for testing attach_feature()"
            self.feature_name = None
            print "--------------------------------------------------------------"

        elif test_name == "Test routine attach_feature_list() in Data":
            print "cleaning up for testing attach_feature_list()"
            self.feature_list = None
            print "--------------------------------------------------------------"

    def test__data__add_anno(self):
        """ Test routine add_anno() in Data """

        self.assertEqual(self.mock_obj.real_data_size, 15)
        self.assertEqual(sorted(self.mock_obj.real_data.keys()), sorted(self.textpair_dic.keys()))

        for textpair_name in self.mock_obj.real_data.keys():
            self.assertEqual(self.mock_obj.real_data[textpair_name].target, self.textpair_dic[textpair_name])

    def test__data__attach_feature(self):
        """ Test routine attach_feature() in Data """

        self.mock_obj.attach_feature("bag_of_words")
        for textpair in self.mock_obj.real_data.values():
            self.assertEqual(textpair.text1.features.keys()[0], self.feature_name)
            self.assertEqual(textpair.text2.features.keys()[0], self.feature_name)

    def test__data__attach_feature_list(self):
        """ Test routine attach_feature_list() in Data """

        self.mock_obj.attach_feature_list(self.feature_list)
        for textpair in self.mock_obj.real_data.values():
            self.assertItemsEqual(textpair.text1.features.keys(), self.feature_list)
            self.assertItemsEqual(textpair.text2.features.keys(), self.feature_list)
Example #14
0
class DataTest(TestBodyData):
    @classmethod
    def setUpClass(cls):
        print "###################### Begin Testing Data Class ######################" + "\n"

    @classmethod
    def tearDownClass(cls):
        print "\n" + "###################### End Testing Data Class ######################"

    def setUp(self):
        test_name = self.shortDescription()
        super(DataTest, self).setUp()
        self.mock_obj = Data("test_data", self.test_korpus)
        self.mock_obj.add_anno(self.anno_file)

        if test_name == "Test routine add_anno() in Data":
            print "setting up for testing add_anno()"
            self.textpair_dic = res.textpair_dic

        elif test_name == "Test routine attach_feature() in Data":
            print "setting up for testing attach_feature()"
            self.feature_name = "bag_of_words"

        elif test_name == "Test routine attach_feature_list() in Data":
            print "setting up for testing attach_feature_list()"
            self.feature_list = res.feature_list

    def tearDown(self):
        test_name = self.shortDescription()
        self.korpus_file = None
        self.anno_file = None
        self.test_korpus = None
        self.mock_obj = None

        if test_name == "Test routine add_anno() in Data":
            print "cleaning up for testing add_anno()"
            self.textpair_dic = None
            print "--------------------------------------------------------------"

        elif test_name == "Test routine attach_feature() in Data":
            print "cleaning up for testing attach_feature()"
            self.feature_name = None
            print "--------------------------------------------------------------"

        elif test_name == "Test routine attach_feature_list() in Data":
            print "cleaning up for testing attach_feature_list()"
            self.feature_list = None
            print "--------------------------------------------------------------"

    def test__data__add_anno(self):
        """ Test routine add_anno() in Data """

        self.assertEqual(self.mock_obj.real_data_size, 15)
        self.assertEqual(sorted(self.mock_obj.real_data.keys()),
                         sorted(self.textpair_dic.keys()))

        for textpair_name in self.mock_obj.real_data.keys():
            self.assertEqual(self.mock_obj.real_data[textpair_name].target,
                             self.textpair_dic[textpair_name])

    def test__data__attach_feature(self):
        """ Test routine attach_feature() in Data """

        self.mock_obj.attach_feature("bag_of_words")
        for textpair in self.mock_obj.real_data.values():
            self.assertEqual(textpair.text1.features.keys()[0],
                             self.feature_name)
            self.assertEqual(textpair.text2.features.keys()[0],
                             self.feature_name)

    def test__data__attach_feature_list(self):
        """ Test routine attach_feature_list() in Data """

        self.mock_obj.attach_feature_list(self.feature_list)
        for textpair in self.mock_obj.real_data.values():
            self.assertItemsEqual(textpair.text1.features.keys(),
                                  self.feature_list)
            self.assertItemsEqual(textpair.text2.features.keys(),
                                  self.feature_list)