How to run IN and NOT IN SPARQL instructions in python rdflib to remove the intersection of two graphs

I'm trying to use the operators INand NOT IN(which, if I understood correctly, were introduced in SPARQL 1.1) on the python implementation of SPARQL (now in rdfextras ), but it seems that the syntax is not recognized.

Consider two sets (A and B). I want to output what is in Set A by deleting what is in Set B.

SELECT ?title WHERE {
   some logic defining ?item and ?SetB
   FILTER (?item NOT IN ?SetB)
}

Perhaps this feature was added in SPARQL 1.1 and is not supported rdfextra, in which case I would like to have a workaround (or how to do this without using a keyword NOT IN)

+5
source share
2

, . rdflib SPARQL parser , , IN NOT IN. , .

, , . NOT IN SPARQL 1.1, IN, . :

FILTER (?item NOT IN (?SetB))

, , spec . edit: . RobV, RLH

, , OPTIONAL bound ( rdflib). - ...

SELECT ?title WHERE {
   some logic defining ?item
   OPTIONAL {
   some logic defining ?SetB
   }
   FILTER (bound(?SetB) && ?setB != ?item)
}

, .

rdlib - , ?SetB. Ant , :

SELECT ?title WHERE {
   some logic defining ?item
   FILTER (?item != <setb_val1> && ?item != <setb_val2> &&
   ... && ?item != <setb_val2>)
}
+4

, , MINUS:

SELECT ?title WHERE {
    ?item ... ITEM CRITERIA ...
    MINUS { ?item ... SET CRITERIA ... }
}

:

SELECT ?title WHERE {
    ?item ex:colour "red" .       # item is red
    MINUS { ?item ex:size "big" } # but not in set of big things
}

NOT IN : , , .

+2

All Articles