query-de76f515580ea6a0f65842537215d94d
Proper escapingI want to use SPARQL to search for basic properties of various user-specified objects, as it can return only the properties I need and their labels as well. I've constructed this basic query:
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?object ?objectLabel ?objectDescription ?country ?countryLabel WHERE {
{
SELECT ?object (COUNT(?label) AS ?languages) WHERE {?object rdfs:label|skos:altLabel "H2O"@en, ?label. }
GROUP BY ?object
ORDER BY DESC (?languages)
LIMIT 1
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "cs,en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?label")
v4("?languages")
v2("?object"):::projected
c5(["bd:serviceParam"]):::iri
c2([sH2O^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString>"]):::literal
c7(["cs,en"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"skos:altLabel"--> c2
v2 --"skos:altLabel"--> v3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"rdfs:label"--> c2
v2 --"rdfs:label"--> v3
end
union0r <== or ==> union0l
end
bind1[/"count(?label)"/]
v3 --o bind1
bind1 --as--o v4
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end