comparison service/mqtt_to_rdf/inference_test.py @ 1589:5c1055be3c36

WIP more debugging, working towards bnode-matching support
author drewp@bigasterisk.com
date Thu, 02 Sep 2021 13:39:27 -0700
parents 0757fafbfdab
children 327202020892
comparison
equal deleted inserted replaced
1588:0757fafbfdab 1589:5c1055be3c36
114 inf = makeInferenceWithRules("{ :a :b ?x . :a :b :c . } => { :new :stmt ?x } .") 114 inf = makeInferenceWithRules("{ :a :b ?x . :a :b :c . } => { :new :stmt ?x } .")
115 implied = inf.infer(N3(":a :b :c .")) 115 implied = inf.infer(N3(":a :b :c ."))
116 self.assertGraphEqual(implied, N3(":new :stmt :c .")) 116 self.assertGraphEqual(implied, N3(":new :stmt :c ."))
117 117
118 118
119 class TestBnodeMatching(WithGraphEqual):
120 def test1(self):
121 inf = makeInferenceWithRules("{ [ :a :b ] . } => { :new :stmt :here } .")
122 implied = inf.infer(N3("[ :a :b ] ."))
123 self.assertGraphEqual(implied, N3(":new :stmt :here ."))
124
125
119 class TestInferenceWithMathFunctions(WithGraphEqual): 126 class TestInferenceWithMathFunctions(WithGraphEqual):
120 127
121 def testBoolFilter(self): 128 def testBoolFilter(self):
122 inf = makeInferenceWithRules("{ :a :b ?x . ?x math:greaterThan 5 } => { :new :stmt ?x } .") 129 inf = makeInferenceWithRules("{ :a :b ?x . ?x math:greaterThan 5 } => { :new :stmt ?x } .")
123 self.assertGraphEqual(inf.infer(N3(":a :b 3 .")), N3("")) 130 self.assertGraphEqual(inf.infer(N3(":a :b 3 .")), N3(""))
124 self.assertGraphEqual(inf.infer(N3(":a :b 5 .")), N3("")) 131 self.assertGraphEqual(inf.infer(N3(":a :b 5 .")), N3(""))
125 self.assertGraphEqual(inf.infer(N3(":a :b 6 .")), N3(":new :stmt 6 .")) 132 self.assertGraphEqual(inf.infer(N3(":a :b 6 .")), N3(":new :stmt 6 ."))
126 133
127 def testStatementGeneratingRule(self): 134 # def testStatementGeneratingRule(self):
128 inf = makeInferenceWithRules("{ :a :b ?x . (?x 1) math:sum ?y } => { :new :stmt ?y } .") 135 # inf = makeInferenceWithRules("{ :a :b ?x . (?x 1) math:sum ?y } => { :new :stmt ?y } .")
129 self.assertGraphEqual(inf.infer(N3(":a :b 3 .")), N3(":new :stmt 4 .")) 136 # self.assertGraphEqual(inf.infer(N3(":a :b 3 .")), N3(":new :stmt 4 ."))
130 137
131 138
132 class TestInferenceWithCustomFunctions(WithGraphEqual): 139 class TestInferenceWithCustomFunctions(WithGraphEqual):
133 140
134 def testAsFarenheit(self): 141 def testAsFarenheit(self):