query-3681ea9c95f4c3bbcca5cf6800fdf3b3
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel_en ?name ?itemLabel_it
{
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint "it.wikipedia.org";
wikibase:api "Generator";
mwapi:generator "categorymembers";
mwapi:gcmtitle "Categoria:Politici italiani del XXI secolo" ;
mwapi:gcmprop "ids|title|type";
mwapi:gcmlimit "max";
mwapi:prop "pageprops|pageterms";
mwapi:wbptterms "label".
# out
?name wikibase:apiOutput mwapi:title. # it-wikipedia article / category name
?item wikibase:apiOutputItem mwapi:item. # wikidata QId for the person's item
?itemLabel_it wikibase:apiOutput "terms/label/term/text()". # Wikidata label in the language of the Wikipedia (it)
}
FILTER BOUND (?item)
FILTER (! BOUND (?itemLabel_it))
OPTIONAL { ?item rdfs:label ?itemLabel_en . filter(lang(?itemLabel_en)="en") }
FILTER (str(?itemLabel_en) != ?name)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?item"):::projected
v1("?itemLabel_en"):::projected
v3("?itemLabel_it"):::projected
v2("?name"):::projected
c17(["pageprops|pageterms"]):::literal
c23(["mwapi:item"]):::iri
c11(["Categoria:Politici italiani del XXI secolo"]):::literal
c5(["it.wikipedia.org"]):::literal
c3(["bd:serviceParam"]):::iri
c24(["terms/label/term/text()"]):::literal
c15(["max"]):::literal
c19(["label"]):::literal
c9(["categorymembers"]):::literal
c21(["mwapi:title"]):::iri
c13(["ids|title|type"]):::literal
c7(["Generator"]):::literal
f0[["str(?itemLabel_en) != ?name"]]
f0 --> v1
f0 --> v2
f1[["not bound(?itemLabel_it)"]]
f1 --> v3
f2[["bound(?item)"]]
f2 --> v4
subgraph s1["http://wikiba.se/ontology#mwapi"]
style s1 stroke-width:4px;
c3 --"mwapi:endpoint"--> c5
c3 --"mwapi:api"--> c7
c3 --"mwapi:generator"--> c9
c3 --"mwapi:gcmtitle"--> c11
c3 --"mwapi:gcmprop"--> c13
c3 --"mwapi:gcmlimit"--> c15
c3 --"mwapi:prop"--> c17
c3 --"mwapi:wbptterms"--> c19
v2 --"mwapi:apiOutput"--> c21
v4 --"mwapi:apiOutputItem"--> c23
v3 --"mwapi:apiOutput"--> c24
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."rdfs:label".-> v1
end