query-ce9e2a0d0902aa0ad37a9c7ce9bc31c6
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
select ?item ?itemLabel ?genreLabel ?article ?name (lang(?name) as ?lang) ?category {
?item wdt:P31 wd:Q5 ;
wdt:P106/wdt:P279* wd:Q266569 .
optional {
?item wdt:P21 ?genre
}
filter (?genre != wd:Q6581097 ).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?article schema:about ?item ; schema:isPartOf <https://en.wikipedia.org/> ; schema:name ?name
########### find articles by their ratings on enwiki
# compute the name of the talk page on enwiki
bind (concat("Talk:", ?name) as ?title)
# find the categories of the talkpage using mwapi
SERVICE wikibase:mwapi {
# Categories that contain these pages
bd:serviceParam wikibase:api "Categories";
wikibase:endpoint "en.wikipedia.org";
mwapi:titles ?title.
# Output the page title and category
?ocategory wikibase:apiOutput mwapi:category .
}
values ?category { #### add relevant (sub?)categories if needed
"Category:Start-Class biography articles"
"Category:Stub-Class biography articles"
"Category:C-Class biography articles"
} filter (?category = ?ocategory)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?article"):::projected
v8("?category"):::projected
v3("?genre")
v4("?item"):::projected
v8("?lang")
v6("?name"):::projected
v2("?ocategory")
v7("?title")
a1((" "))
c18(["Categories"]):::literal
c6(["wd:Q266569"]):::iri
c14([https://en.wikipedia.org/]):::iri
c20(["en.wikipedia.org"]):::literal
c9(["bd:serviceParam"]):::iri
c23(["mwapi:category"]):::iri
c3(["wd:Q5"]):::iri
c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["?category = ?ocategory"]]
f0 --> v8
f0 --> v2
f1[["?genre != 'wd:Q6581097'"]]
f1 --> v3
v4 --"wdt:P31"--> c3
v4 --"wdt:P106"--> a1
a1 --"wdt:P279"--> c6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P21".-> v3
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"mwapi:language"--> c11
end
v5 --"schema:about"--> v4
v5 --"schema:isPartOf"--> c14
v5 --"schema:name"--> v6
bind2[/"concat('Talk:',?name)"/]
v6 --o bind2
bind2 --as--o v7
subgraph s2["http://wikiba.se/ontology#mwapi"]
style s2 stroke-width:4px;
c9 --"mwapi:api"--> c18
c9 --"mwapi:endpoint"--> c20
c9 --"mwapi:titles"--> v7
v2 --"mwapi:apiOutput"--> c23
end
bind3[/VALUES ?category/]
bind3-->v8
bind30(["Category:Start-Class biography articles"])
bind30 --> bind3
bind31(["Category:Stub-Class biography articles"])
bind31 --> bind3
bind32(["Category:C-Class biography articles"])
bind32 --> bind3
bind4[/"?name"/]
v6 --o bind4
bind4 --as--o v8