Skip to content Skip to sidebar Skip to footer

Python Rdflib Transitive Query

I am fairly new with using rdflib and my problem is rather simple. I have several n-triple files containing a quite considerate amount of data, while each file has the same domain

Solution 1:

After checking more of the rdflib documentation I figured out the following solution:

...
formainGraphin mainGraphs:
    fors,p,o in mainGraph.triples( (None, OWL.sameAs, None) ):
        forgraphin graphs:
            fors1,p1,o1 in graph.triples( (s,p,None) ):
                backlinks.add( (o1, OWL.sameAs, o) )
...

It is considerably faster. If someone has a faster solution I would greatly appreciate it if they would post it.

Post a Comment for "Python Rdflib Transitive Query"