sparqlwikidata-query-service

Getting from Property Statement link to Property Label with Sqarql/wikidata


first time poster here, because i am desperate.

in a Sparql query i have a result column, where pLabel is not accualy the property, but the ps:/pq: type. i would like to get the label of the property (ex. ps:P61-> "winner"). how do i achieve that?

SELECT DISTINCT ?topstatement ?topstatementLabel ?target ?targetLabel ?p ?pLabel ?pointInTime {
  VALUES (?target) {(wd:Q937)}
    ?statement (
              pq:P571
              |pq:P575
              |pq:P585
             ) ?pointInTime .
  ?topstatement ?wdq ?statement .
  ?statement ?p ?target .
  
  SERVICE wikibase:label {bd:serviceParam wikibase:language 'en'}

}

on wikdiata query service

i tried by myself on wikidata query service and after hours i even tried ai which could not help me eighter


Solution

  • Property labels in Wikidata are linked to the property entities. In the case if qualifier, the property entity is linked to the property with wikibase:qualifier, so you'll get it this way

    SELECT DISTINCT ?topstatement ?topstatementLabel ?target ?targetLabel ?p ?pLabel ?pointInTime {
      VALUES (?target) {(wd:Q937)}
        ?statement (
                  pq:P571|pq:P575|pq:P585
                 ) ?pointInTime .
      ?topstatement ?wdq ?statement .
      ?statement ?p ?target .
      
      ?qualifierEntity wikibase:qualifier ?p;
                       rdfs:label ?pLabel.
      FILTER(LANG(?pLabel)="en")
      SERVICE wikibase:label {bd:serviceParam wikibase:language 'en'}
    
    }
    

    For direct properties, you should use wikibase:directClaim