Mercurial > code > home > repos > homeauto
comparison service/mqtt_to_rdf/inference.py @ 1602:e3c44ac6d3c5
do findEvals once at setRules time
author | drewp@bigasterisk.com |
---|---|
date | Mon, 06 Sep 2021 00:56:13 -0700 |
parents | 30463df12d89 |
children | 7f8bf68534ed |
comparison
equal
deleted
inserted
replaced
1601:30463df12d89 | 1602:e3c44ac6d3c5 |
---|---|
77 return usedByFuncs | 77 return usedByFuncs |
78 | 78 |
79 def _applyFunctionsIteration(self, lhs, usedByFuncs: Graph): | 79 def _applyFunctionsIteration(self, lhs, usedByFuncs: Graph): |
80 before = len(self.binding) | 80 before = len(self.binding) |
81 delta = 0 | 81 delta = 0 |
82 for ev in Evaluation.findEvals(lhs.graph): | 82 for ev in lhs.evaluations: |
83 log.debug(f'{INDENT*3} found Evaluation') | 83 log.debug(f'{INDENT*3} found Evaluation') |
84 | 84 |
85 newBindings, usedGraph = ev.resultBindings(self.binding) | 85 newBindings, usedGraph = ev.resultBindings(self.binding) |
86 usedByFuncs += usedGraph | 86 usedByFuncs += usedGraph |
87 self._addNewBindings(newBindings) | 87 self._addNewBindings(newBindings) |
150 varsAndBnodesInStmt = [term for term in ruleStmt if isinstance(term, (Variable, BNode))] | 150 varsAndBnodesInStmt = [term for term in ruleStmt if isinstance(term, (Variable, BNode))] |
151 self.lhsBindables.update(varsAndBnodesInStmt) | 151 self.lhsBindables.update(varsAndBnodesInStmt) |
152 self.lhsBnodes.update(x for x in varsAndBnodesInStmt if isinstance(x, BNode)) | 152 self.lhsBnodes.update(x for x in varsAndBnodesInStmt if isinstance(x, BNode)) |
153 if not varsAndBnodesInStmt: | 153 if not varsAndBnodesInStmt: |
154 self.staticRuleStmts.add(ruleStmt) | 154 self.staticRuleStmts.add(ruleStmt) |
155 | |
156 self.evaluations = list(Evaluation.findEvals(self.graph)) | |
157 | |
155 | 158 |
156 def findCandidateBindings(self, workingSet: ReadOnlyWorkingSet) -> Iterator[CandidateBinding]: | 159 def findCandidateBindings(self, workingSet: ReadOnlyWorkingSet) -> Iterator[CandidateBinding]: |
157 """bindings that fit the LHS of a rule, using statements from workingSet and functions | 160 """bindings that fit the LHS of a rule, using statements from workingSet and functions |
158 from LHS""" | 161 from LHS""" |
159 log.debug(f'{INDENT*3} nodesToBind: {self.lhsBindables}') | 162 log.debug(f'{INDENT*3} nodesToBind: {self.lhsBindables}') |