GDD-Nantes / FedShop

Code for FedShop: The Federated Shop Benchmark
GNU General Public License v3.0
8 stars 0 forks source link

Special case for q03 #17

Closed mhoangvslev closed 1 year ago

mhoangvslev commented 1 year ago

Given this query:

PREFIX bsbm: <http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

SELECT ?product ?label
WHERE {
    ?localProduct owl:sameAs ?product .
    ?localProduct rdfs:label ?label .
    # const ?ProductType
    ?localProduct rdf:type ?localProductType .
    ?localProductType owl:sameAs ?ProductType .

    # const ?ProductFeature1
    ?localProduct bsbm:productFeature ?localProductFeature1 .
    ?localProductFeature1 owl:sameAs ?ProductFeature1 .
    ?localProduct bsbm:productPropertyNumeric1 ?p1 .
    # const ?x < ?p1 
    FILTER ( ?p1 > ?x ) 
    ?localProduct bsbm:productPropertyNumeric3 ?p3 .
    # const ?y > ?p3
    FILTER (?p3 < ?y )

    OPTIONAL { 
        # const not ?ProductFeature2
        ?localProduct bsbm:productFeature ?localProductFeature2 .
        ?localProductFeature2 owl:sameAs ?ProductFeature2 .
        ?localProduct rdfs:label ?testVar 
    }
    FILTER (!bound(?testVar)) 
}
ORDER BY ?label
LIMIT 10

The filter FILTER (!bound(?testVar)) makes it very hard to evaluate the query in the current workflow, i.e, injecting one by one constant and execute-to-fill. To make it work, you need:

mhoangvslev commented 1 year ago

Solution:

PREFIX bsbm: <http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

SELECT ?product ?label
WHERE {
    ?localProduct owl:sameAs ?product .
    ?localProduct rdfs:label ?label .
    # const ?ProductType
    ?localProduct rdf:type ?localProductType .
    ?localProductType owl:sameAs ?ProductType .

    # const ?ProductFeature1
    ?localProduct bsbm:productFeature ?localProductFeature1 .
    ?localProductFeature1 owl:sameAs ?ProductFeature1 .
    ?localProduct bsbm:productPropertyNumeric1 ?p1 .
    # const ?x < ?p1 
    FILTER ( ?p1 > ?x ) 
    ?localProduct bsbm:productPropertyNumeric3 ?p3 .
    # const ?y > ?p3
    FILTER (?p3 < ?y )

    OPTIONAL { 
        # const!* not ?ProductFeature2
        ?localProduct bsbm:productFeature ?localProductFeature2 .
        ?localProductFeature2 owl:sameAs ?ProductFeature2 .
        ?localProduct rdfs:label ?testVar 
    }
    FILTER (!bound(?testVar)) 
}
ORDER BY ?label
LIMIT 10

What it means for the injection engine:

  1. ?ProductFeature2 will be injected exclusively, i.e without the other constants.
  2. Evaluate the injected query to obtain the remaining constants.