Beispiel #1
0
 def __hash__(self):
     if self._hash is None:
         from FuXi.Rete.Network import HashablePatternList
         antHash = HashablePatternList(
             [term.toRDFTuple() for term in self.body], skipBNodes=True)
         consHash = HashablePatternList(
             [term.toRDFTuple() for term in self.head], skipBNodes=True)
         self._bodyHash = hash(antHash)
         self._headHash = hash(consHash)
         self._hash = hash((self._headHash, self._bodyHash))
     return self._hash
Beispiel #2
0
 def __init__(self, body, head):
     self.body = body
     self.head = head
     from FuXi.Rete.Network import HashablePatternList
     antHash = HashablePatternList([term.toRDFTuple() for term in body],
                                   skipBNodes=True)
     consHash = HashablePatternList([term.toRDFTuple() for term in head],
                                    skipBNodes=True)
     self._bodyHash = hash(antHash)
     self._headHash = hash(consHash)
     self._hash = hash((self._headHash, self._bodyHash))
Beispiel #3
0
 def __init__(self, body, head):
     self.body = body
     self.head = head
     if isinstance(head, Uniterm):
         from FuXi.Rete.Network import HashablePatternList
         try:
             antHash = HashablePatternList(
                 [term.toRDFTuple() for term in body], skipBNodes=True)
             consHash = HashablePatternList(
                 [term.toRDFTuple() for term in head], skipBNodes=True)
             self._bodyHash = hash(antHash)
             self._headHash = hash(consHash)
             self._hash = hash((self._headHash, self._bodyHash))
         except:
             self._hash = None
     else:
         self._hash = None
Beispiel #4
0
    def __hash__(self):
        """
        >>> g = Graph()
        >>> lit1 = (Variable('X'), RDF.type, Variable('Y'))
        >>> q1 = EDBQuery([BuildUnitermFromTuple(lit1)], g)
        >>> q2 = EDBQuery([BuildUnitermFromTuple(lit1)], g)
        >>> q1 == q2
        True
        >>> d = {q1:True}
        >>> q2 in d
        True

        """
        from FuXi.Rete.Network import HashablePatternList
        conj = HashablePatternList(
            [term.toRDFTuple() for term in self.formulae], skipBNodes=True)
        return hash(conj)
 def testCombineUriAndLiteral(self):
     # This is a simplified version of input that happens in real usage with a rule like this:
     # { ?c :p1 ?uri . } => { ?c :p2 (" " ?uri) . } .
     hpl = HashablePatternList(items=[(URIRef('http://example.com/'),),
                                      (Literal(' '),)])
     hash(hpl)