예제 #1
0
    def test_not_match_vars_subject_predicate_object(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        matched = collection.not_match_to_vars("?x", "?y", "?z")
        self.assertIsNotNone(matched)
        self.assertEqual(0, len(matched))
예제 #2
0
    def test_not_match_vars_subject(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        not_matched = collection.not_match_to_vars("?x")
        self.assertIsNotNone(not_matched)
        self.assertEqual(0, len(not_matched))
예제 #3
0
    def test_not_match_vars(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        matched = collection.not_match_to_vars()
        self.assertIsNotNone(matched)
        self.assertEqual(0, len(matched))
예제 #4
0
    def test_not_match_vars_subject_predicate_object(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        matched = collection.not_match_to_vars("?x", "?y", "?z")
        self.assertIsNotNone(matched)
        self.assertEquals(0, len(matched))
예제 #5
0
    def test_not_match_vars_subject(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        not_matched = collection.not_match_to_vars("?x")
        self.assertIsNotNone(not_matched)
        self.assertEquals(0, len(not_matched))
예제 #6
0
    def test_not_match_vars(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        matched = collection.not_match_to_vars()
        self.assertIsNotNone(matched)
        self.assertEquals(0, len(matched))
예제 #7
0
    def test_not_match_vars_subject_with_predicate_params(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        not_matched = collection.not_match_to_vars(subject="?x", predicate="LEGS")
        self.assertIsNotNone(not_matched)
        self.assertEquals(1, len(not_matched))
        self.assertTrue([['?x', 'ELEPHANT'], ['pred', 'TRUNK'], ['obj', 'true']] in not_matched)
예제 #8
0
    def test_not_match_vars_subject_with_predicate_params(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        not_matched = collection.not_match_to_vars(subject="?x",
                                                   predicate="LEGS")
        self.assertIsNotNone(not_matched)
        self.assertEqual(1, len(not_matched))
        self.assertTrue([['?x', 'ELEPHANT'], ['pred', 'TRUNK'],
                         ['obj', 'true']] in not_matched)
예제 #9
0
    def test_not_match_vars_object_with_subject_predicate_params(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        matched = collection.not_match_to_vars(subject="MONKEY", predicate="LEGS", obj="?x")
        self.assertIsNotNone(matched)
        self.assertEqual(3, len(matched))
        self.assertTrue([['subj', 'ELEPHANT'], ['pred', 'TRUNK'], ['?x', 'true']] in matched)
        self.assertTrue([['subj', 'ZEBRA'], ['pred', 'LEGS'], ['?x', '4']] in matched)
        self.assertTrue([['subj', 'BIRD'], ['pred', 'LEGS'], ['?x', '2']] in matched)
예제 #10
0
    def test_not_match_vars_object_with_subject_params(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        matched = collection.not_match_to_vars(subject="MONKEY", obj="?x")
        self.assertIsNotNone(matched)
        self.assertEqual(3, len(matched))
        self.assertTrue([['subj', 'ELEPHANT'], ['pred', 'TRUNK'],
                         ['?x', 'true']] in matched)
        self.assertTrue(
            [['subj', 'ZEBRA'], ['pred', 'LEGS'], ['?x', '4']] in matched)
        self.assertTrue(
            [['subj', 'BIRD'], ['pred', 'LEGS'], ['?x', '2']] in matched)
예제 #11
0
    def test_not_match_vars_subject_with_predicate_object_params(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        matched = collection.not_match_to_vars(subject="?x",
                                               predicate="LEGS",
                                               obj="2")
        self.assertIsNotNone(matched)
        self.assertEquals(2, len(matched))
        self.assertTrue(
            [['?x', 'ZEBRA'], ['pred', 'LEGS'], ['obj', '4']] in matched)
        self.assertTrue([['?x', 'ELEPHANT'], ['pred', 'TRUNK'],
                         ['obj', 'true']] in matched)
예제 #12
0
    def test_unify_on_single_var_with_not(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        collection.add_entity("MONKEY", "LEGS", "2", "ANIMALS")
        collection.add_entity("MONKEY", "HASFUR", "true", "ANIMALS")
        collection.add_entity("ZEBRA", "LEGS", "4", "ANIMALS")
        collection.add_entity("BIRD", "LEGS", "2", "ANIMALS")
        collection.add_entity("ELEPHANT", "TRUNK", "true", "ANIMALS")

        set1 = collection.match_to_vars("?x", "LEGS", "2")
        set2 = collection.not_match_to_vars("?x", "HASFUR", "true")

        unified = collection.unify(["?x"], [set1, set2])
        self.assertIsNotNone(unified)
        self.assertEqual(1, len(unified))
        self.assertTrue([['?x', 'BIRD']] in unified)
예제 #13
0
    def test_unify_on_single_var_with_not(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        collection.add_entity("MONKEY", "LEGS", "2")
        collection.add_entity("MONKEY", "HASFUR", "true")
        collection.add_entity("ZEBRA", "LEGS", "4")
        collection.add_entity("BIRD", "LEGS", "2")
        collection.add_entity("ELEPHANT", "TRUNK", "true")

        set1 = collection.match_to_vars("?x", "LEGS", "2")
        set2 = collection.not_match_to_vars("?x", "HASFUR", "true")

        unified = collection.unify(["?x"], [set1, set2])
        self.assertIsNotNone(unified)
        self.assertEquals(1, len(unified))
        self.assertTrue([['?x', 'BIRD']] in unified)
    def test_not_match_vars_subject_predicate_with_subject_object_params(self):
        collection = RDFCollection()
        self.assertIsNotNone(collection)

        self.add_data(collection)

        matched = collection.not_match_to_vars(subject="MONKEY",
                                               predicate="?y",
                                               obj="2")
        self.assertIsNotNone(matched)
        self.assertEqual(4, len(matched))
        self.assertTrue(
            [['subj', 'MONKEY'], ['?y', 'HASFUR'], ['obj', 'TRUE']] in matched)
        self.assertTrue([['subj', 'ELEPHANT'], ['?y', 'TRUNK'],
                         ['obj', 'TRUE']] in matched)
        self.assertTrue(
            [['subj', 'ZEBRA'], ['?y', 'LEGS'], ['obj', '4']] in matched)
        self.assertTrue(
            [['subj', 'BIRD'], ['?y', 'LEGS'], ['obj', '2']] in matched)