| 50 | await self._store_results(link, found_facts, operation) |
| 51 | |
| 52 | async def _store_results(self, link, facts, operation=None): |
| 53 | facts_covered = [] |
| 54 | for relationship in self.model: |
| 55 | matches = [] |
| 56 | for fact in facts: |
| 57 | if fact.trait in relationship: |
| 58 | matches.append(fact) |
| 59 | facts_covered.append(fact) |
| 60 | for pair in itertools.combinations(matches, r=2): |
| 61 | if pair[0].trait != pair[1].trait: |
| 62 | await link.create_relationships([Relationship(source=pair[0], edge='has', target=pair[1])], |
| 63 | operation=operation) |
| 64 | for f in [x for x in facts if x not in facts_covered]: |
| 65 | await link.save_fact(operation=operation, fact=f, score=1, relationship=[]) |