query-f9acd927f4e382edfea0e930c10f4178

rq turtle/ttl

title:Most common properties (excluding external ids) for a type of item on a given Wikipedia SELECT ?id (COUNT(DISTINCT ?item)*100/?total AS ?percent) # ?idlabel WITH { SELECT $WIKIPEDIA $TYPE WHERE { VALUES $WIKIPEDIA { https://ary.wikipedia.org/ } VALUES $TYPE { wd:Q5398426 } } } AS %constants WITH { SELECT ?item WHERE { INCLUDE %constants ?item wdt:P31/wdt:P279? $TYPE . ?arwp schema:about ?item ; schema:isPartOf $WIKIPEDIA } } AS %list WITH { SELECT (COUNT(?item) AS ?total) WHERE { INCLUDE %constants ?item wdt:P31/wdt:P279? $TYPE . ?arwp schema:about ?item ; schema:isPartOf $WIKIPEDIA } } AS %total WHERE { include %list . include %total . ?item ?p [] . ?id wikibase:claim ?p FILTER(?id != wd:P31). MINUS { ?id wikibase:propertyType wikibase:ExternalId } # ?id rdfs:label ?idlabel FILTER (lang(?idlabel) = "en") } GROUP BY ?id ?total # ?idlabel ORDER BY DESC(?percent) LIMIT 20

Use at

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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#title:Most common properties (excluding external ids) for a type of item on a given Wikipedia
SELECT ?id (COUNT(DISTINCT ?item)*100/?total AS ?percent) # ?idlabel
WHERE {
   {
 SELECT ?item WHERE {
   { SELECT $WIKIPEDIA $TYPE WHERE {
  VALUES $WIKIPEDIA  { <https://ary.wikipedia.org/> }
  VALUES $TYPE { wd:Q5398426 }
  } }  ?item wdt:P31/wdt:P279? $TYPE .
   ?arwp schema:about ?item ; schema:isPartOf $WIKIPEDIA
 } }.
   { SELECT (COUNT(?item) AS ?total) WHERE {
   { SELECT $WIKIPEDIA $TYPE WHERE {
  VALUES $WIKIPEDIA  { <https://ary.wikipedia.org/> }
  VALUES $TYPE { wd:Q5398426 }
  } }  ?item wdt:P31/wdt:P279? $TYPE .
   ?arwp schema:about ?item ; schema:isPartOf $WIKIPEDIA
 } }.
  ?item ?p [] .
  ?id wikibase:claim ?p FILTER(?id != wd:P31).
  MINUS { ?id wikibase:propertyType wikibase:ExternalId }
 #  ?id rdfs:label ?idlabel FILTER (lang(?idlabel) = "en")
} GROUP BY ?id ?total # ?idlabel
ORDER BY DESC(?percent)
LIMIT 20

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?TYPE") v7("?WIKIPEDIA") v6("?arwp") v2("?id"):::projected v5("?item") v8("?p") v9("?percent") v7("?total"):::projected a3((" ")) a1((" ")) a2((" ")) c8(["wikibase:ExternalId"]):::iri f0[["?id != 'wd:P31'"]] f0 --> v2 bind1[/VALUES ?WIKIPEDIA/] bind1-->v7 bind10([https://ary.wikipedia.org/]) bind10 --> bind1 bind2[/VALUES ?TYPE/] bind2-->v7 bind20(["wd:Q5398426"]) bind20 --> bind2 v5 --"wdt:P31"--> a1 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; a1 --"wdt:P279"--> v7 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; end union0r <== or ==> union0l end v6 --"schema:about"--> v5 v6 --"schema:isPartOf"--> v7 bind3[/VALUES ?WIKIPEDIA/] bind3-->v7 bind30([https://ary.wikipedia.org/]) bind30 --> bind3 bind4[/VALUES ?TYPE/] bind4-->v7 bind40(["wd:Q5398426"]) bind40 --> bind4 v5 --"wdt:P31"--> a2 subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; a2 --"wdt:P279"--> v7 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; end union1r <== or ==> union1l end v6 --"schema:about"--> v5 v6 --"schema:isPartOf"--> v7 bind6[/"count(?item)"/] v5 --o bind6 bind6 --as--o v7 v5 -->v8--> a3 v2 --"wikibase:claim"--> v8 subgraph minus7["MINUS"] style minus7 stroke-width:6px,fill:pink,stroke:red; v2 --"wikibase:propertyType"--> c8 end bind9[/" * '100^^xsd:integer' / ?total"/] null --o bind9 v7 --o bind9 bind9 --as--o v9