diff service/reasoning/reasoning.py @ 283:0b0fb67b0b3a

fix input/output statement ambiguity problem by allowing quoted output statements Ignore-this: 677a7f6bc1df1788c9b12d5fd87e841a
author drewp@bigasterisk.com
date Fri, 06 May 2016 18:38:18 -0700
parents 0498634eba17
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: