Retrieve Units for Values of PropertyType Quantity in QLever Wikidata Query

42 views Asked by At

I'm encountering an issue while attempting to retrieve the units associated with values of propertyType Quantity in QLever Wikidata Query. In my query, I've attempted to include the units for distinguishing values such as meters from kilometers. The query I've provided below worked perfectly fine in the Wikidata Query Service but fails to retrieve the units in QLever Wikidata Query:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>

SELECT DISTINCT ?item ?itemLabel ?property ?propertyLabel ?value ?unit WHERE {
  {
    {
      SELECT DISTINCT ?instanceOf WHERE {
        VALUES (?startItem) { (wd:Q556) }
        ?startItem (wdt:P31) ?instanceOf.
      }
    }
    ?item (wdt:P31) ?instanceOf.
    ?item rdfs:label ?itemLabel.
    FILTER(LANG(?itemLabel) = "en")
  } UNION {
    VALUES (?item) { (wd:Q556) }
    ?item rdfs:label ?itemLabel.
    FILTER(LANG(?itemLabel) = "en")
  }
  ?item ?p ?value.
  ?property wikibase:directClaim ?p.
  ?property rdfs:label ?propertyLabel.
  FILTER(LANG(?propertyLabel) = "en")
  ?property rdf:type wikibase:Property.
  ?property wikibase:propertyType wikibase:Quantity.
  OPTIONAL {
    ?value wikibase:quantityAmount ?amount.
    ?value wikibase:quantityUnit ?unit.
  }
}

Could someone assist me in modifying this query to retrieve the corresponding units along with the values? I've tried various approaches, but none seem to work in QLever Wikidata Query.

0

There are 0 answers