My question is how I can extract all properties and their respective labels that are also rendered on the webpage from wikidata preferably over SPARQL.
Take for example the Google entry on wikidata. For the property P414 (stock exchange) or P159 there are subproperties like P969 (located at street address). They actually show up once you query wbgetentities
as qualifieres. The problem with wbgetentities
is that the labels are missing. I get the desired output (e.g. wdt:P17 => country => United States of America
) with the following SPARQL query:
SELECT ?prop_id ?prop_label ?prop_val_label WHERE {
VALUES (?company) {
(wd:Q95)
}
?company ?prop_id ?company_item.
?wd wikibase:directClaim ?prop_id.
?wd rdfs:label ?prop_label.
OPTIONAL {
?company_item rdfs:label ?prop_val.
FILTER((LANG(?prop_val)) = "en")
}
BIND(COALESCE(?prop_val, ?companyItem) AS ?prop_val_label)
FILTER((LANG(?prop_label)) = "en")
}
But those "subproperties" are missing because they are not under direct claims. To extract a single statements qualifier I can do:
SELECT ?company ?hq ?country WHERE {
wd:Q95 p:P159 ?company.
OPTIONAL {
?company ps:P159 ?hq.
?company pq:P17 ?country.
}
}
But the question is if there is a way to combine everything to one query?