comparison service/mqtt_to_rdf/inference.py @ 1613:03ed8c9abd5b

forget GRAPH_ID optimization in this case
author drewp@bigasterisk.com
date Mon, 06 Sep 2021 23:03:51 -0700
parents 272f78d4671a
children 97b2c3cfdb83
comparison
equal deleted inserted replaced
1612:272f78d4671a 1613:03ed8c9abd5b
25 25
26 ROOM = Namespace("http://projects.bigasterisk.com/room/") 26 ROOM = Namespace("http://projects.bigasterisk.com/room/")
27 LOG = Namespace('http://www.w3.org/2000/10/swap/log#') 27 LOG = Namespace('http://www.w3.org/2000/10/swap/log#')
28 MATH = Namespace('http://www.w3.org/2000/10/swap/math#') 28 MATH = Namespace('http://www.w3.org/2000/10/swap/math#')
29 29
30 # Graph() makes a BNode if you don't pass
31 # identifier, which can be a bottleneck.
32 GRAPH_ID = URIRef('dont/care')
33
34 30
35 @dataclass 31 @dataclass
36 class Lhs: 32 class Lhs:
37 graph: Graph 33 graph: Graph
38 34
78 74
79 stats['permCountSucceeding'] += 1 75 stats['permCountSucceeding'] += 1
80 yield binding 76 yield binding
81 77
82 def _allStaticStatementsMatch(self, workingSet: ReadOnlyWorkingSet) -> bool: 78 def _allStaticStatementsMatch(self, workingSet: ReadOnlyWorkingSet) -> bool:
79 # bug: see TestSelfFulfillingRule.test3 for a case where this rule's
80 # static stmt is matched by a non-static stmt in the rule itself
83 for ruleStmt in self.staticRuleStmts: 81 for ruleStmt in self.staticRuleStmts:
84 if ruleStmt not in workingSet: 82 if ruleStmt not in workingSet:
85 log.debug(f'{INDENT*3} {ruleStmt} not in working set- skip rule') 83 log.debug(f'{INDENT*3} {ruleStmt} not in working set- skip rule')
86 return False 84 return False
87 return True 85 return True
151 class BoundLhs: 149 class BoundLhs:
152 lhs: Lhs 150 lhs: Lhs
153 binding: CandidateBinding 151 binding: CandidateBinding
154 152
155 def __post_init__(self): 153 def __post_init__(self):
156 self.usedByFuncs = Graph(identifier=GRAPH_ID) 154 self.usedByFuncs = Graph()
157 self._applyFunctions() 155 self._applyFunctions()
158 156
159 self.graphWithoutEvals = self.lhs.graph - self.usedByFuncs 157 self.graphWithoutEvals = self.lhs.graph - self.usedByFuncs
160 158
161 def _applyFunctions(self): 159 def _applyFunctions(self):