コード例 #1
0
    def test_get_triples_one_doc_one_triple(self):
        """
        Tests function when there is one doc with one single words triple
        """
        test_result = dd.get_triples([self.one_doc_one_triple])

        right_answer = [("hello", "TO_THE", "world")]

        self.assertEqual(test_result, right_answer)
コード例 #2
0
    def test_get_triples_one_doc_no_triples(self):
        """
        Tests that there are no triples returned when the doc's list is empty
        """
        test_result = dd.get_triples([self.one_doc_no_triples])

        right_answer = []

        self.assertEqual(test_result, right_answer)
コード例 #3
0
    def test_get_triples_one_doc_compound_triples(self):
        """
        Tests that the function successfully merges compound entities
        """
        test_result = dd.get_triples([self.one_doc_compound_triples])

        right_answer = [("hello", "TO_THE", "world"),
                        ("I", "LIKE", "you world")]

        self.assertEqual(test_result, right_answer)
コード例 #4
0
    def test_get_triples_one_doc_multiple_triples(self):
        """
        Tests function when there is one doc with multiple triples with single 
        word entities
        """
        test_result = dd.get_triples([self.one_doc_multiple_triples])

        right_answer = [("hello", "TO_THE", "world"), ("I", "LIKE", "you"),
                        ("I", "LIKE", "world")]

        self.assertEqual(test_result, right_answer)
コード例 #5
0
    def test_get_triples_multi_doc_mixed(self):
        """
        Test function when all three individual doc cases are mixed
        """
        docs = [
            self.one_doc_no_triples, self.one_doc_one_triple,
            self.one_doc_multiple_triples, self.one_doc_compound_triples
        ]
        test_result = dd.get_triples(docs)

        right_answer = [("hello", "TO_THE", "world"),
                        ("hello", "TO_THE", "world"), ("I", "LIKE", "you"),
                        ("I", "LIKE", "world"), ("hello", "TO_THE", "world"),
                        ("I", "LIKE", "you world")]

        self.assertEqual(test_result, right_answer)