Mercurial > code > home > repos > homeauto
comparison service/mqtt_to_rdf/inference_test.py @ 1694:73abfd4cf5d0
new html log and other refactoring as i work on the advanceTheStack problems
https://bigasterisk.com/post/inference/2021-09-27_11-11.png
author | drewp@bigasterisk.com |
---|---|
date | Mon, 27 Sep 2021 11:22:09 -0700 |
parents | 2883da14847c |
children |
comparison
equal
deleted
inserted
replaced
1693:0455a1e18e4f | 1694:73abfd4cf5d0 |
---|---|
2 also see https://github.com/w3c/N3/tree/master/tests/N3Tests | 2 also see https://github.com/w3c/N3/tree/master/tests/N3Tests |
3 """ | 3 """ |
4 import unittest | 4 import unittest |
5 from decimal import Decimal | 5 from decimal import Decimal |
6 from typing import cast | 6 from typing import cast |
7 | 7 from pathlib import Path |
8 from rdflib import ConjunctiveGraph, Graph, Literal, Namespace | 8 from rdflib import ConjunctiveGraph, Graph, Literal, Namespace |
9 from rdflib.parser import StringInputSource | 9 from rdflib.parser import StringInputSource |
10 | 10 |
11 from inference import Inference | 11 from inference import Inference |
12 from rdflib_debug_patches import patchBnodeCounter, patchSlimReprs | 12 from rdflib_debug_patches import patchBnodeCounter, patchSlimReprs |
187 self.assertResult(implied) | 187 self.assertResult(implied) |
188 | 188 |
189 def testProdCase(self): | 189 def testProdCase(self): |
190 inf = makeInferenceWithRules(''' | 190 inf = makeInferenceWithRules(''' |
191 { | 191 { |
192 :AirQualitySensor :nameRemap [ | 192 :AirQualitySensor :nameRemap [ |
193 :sensorName ?sensorName; | 193 :sensorName ?sensorName; |
194 :measurementName ?measurement | 194 :measurementName ?measurement |
195 ] . | 195 ] . |
196 } => { | 196 } => { |
197 :a :b ?sensorName. | 197 :a :b ?sensorName. |
198 :d :e ?measurement. | 198 :d :e ?measurement. |
199 } . | 199 } . |
200 ''') | 200 ''') |
201 implied = inf.infer( | 201 implied = inf.infer( |
202 N3(''' | 202 N3(''' |
203 :AirQualitySensor :nameRemap | 203 :AirQualitySensor :nameRemap |
411 } . | 411 } . |
412 ''') | 412 ''') |
413 out = inf.infer(N3(''' | 413 out = inf.infer(N3(''' |
414 :airQualityIndoor a :AirQualitySensor; :label "air_quality_indoor" . | 414 :airQualityIndoor a :AirQualitySensor; :label "air_quality_indoor" . |
415 :airQualityOutdoor a :AirQualitySensor; :label "air_quality_outdoor" . | 415 :airQualityOutdoor a :AirQualitySensor; :label "air_quality_outdoor" . |
416 ''')) | 416 '''), Path('/tmp/log.html')) |
417 self.assertGraphEqual(out, N3(''' | 417 self.assertGraphEqual(out, N3(''' |
418 :airQualityIndoor :statementSourceBase <http://projects.bigasterisk.com/room/mqttSource/air_quality_indoor> . | 418 :airQualityIndoor :statementSourceBase <http://projects.bigasterisk.com/room/mqttSource/air_quality_indoor> . |
419 :airQualityOutdoor :statementSourceBase <http://projects.bigasterisk.com/room/mqttSource/air_quality_outdoor> . | 419 :airQualityOutdoor :statementSourceBase <http://projects.bigasterisk.com/room/mqttSource/air_quality_outdoor> . |
420 ''')) | 420 ''')) |
421 | 421 |