diff service/reasoning/reasoning.py @ 1088:0f6128740000

fix input/output statement ambiguity problem by allowing quoted output statements Ignore-this: 677a7f6bc1df1788c9b12d5fd87e841a darcs-hash:1cbae17740cecff867c9bd54d9b9f0f96e58b462
author drewp <drewp@bigasterisk.com>
date Fri, 06 May 2016 18:38:18 -0700
parents 806d2f633775
children 95f72a22965d
line wrap: on
line diff
--- a/service/reasoning/reasoning.py	Fri May 06 17:34:54 2016 -0700
+++ b/service/reasoning/reasoning.py	Fri May 06 18:38:18 2016 -0700
@@ -42,7 +42,16 @@
 DEV = Namespace("http://projects.bigasterisk.com/device/")
 
 NS = {'': ROOM, 'dev': DEV}
-        
+
+
+def unquoteStatement(graph, stmt):
+    # todo: use the standard schema for this, or eliminate
+    # it in favor of n3 graph literals.
+    return (graph.value(stmt, ROOM['subj']),
+            graph.value(stmt, ROOM['pred']),
+            graph.value(stmt, ROOM['obj']))
+
+
 class Reasoning(object):
     def __init__(self):
         self.prevGraph = None
@@ -104,6 +113,10 @@
             
             g = inputGraph.getGraph()
             self.inferred = self._makeInferred(g)
+
+            for qs in self.inferred.objects(ROOM['output'], ROOM['statement']):
+                self.inferred.add(unquoteStatement(self.inferred, qs))
+            
             [self.inferred.add(s) for s in ruleStatStmts]
 
             if oneShot: