query-1821423d7231352b9d618b161808cc9e

rq turtle/ttl

Properties with 5 or less Model Item statements, with links to query for top 10 items using the property SELECT ?property ?propertyLabel ?model_item_statement_count ?query_top_ten_items WHERE { { SELECT DISTINCT ?property (COUNT(?modelItem) as ?model_item_statement_count) WHERE { ?property rdf:type wikibase:Property . #all properties OPTIONAL { ?property wdt:P5869 ?modelItem } #with model items if present } GROUP BY ?property }

FILTER (?model_item_statement_count < 5) #only show properties with 5 or less Model Item statements BIND (xsd:integer( SUBSTR(STR(?property), 33) ) as ?propNumber) #use property number as a basic rank for 'top' properties BIND ("https://query.wikidata.org/embed.html#SELECT%20%3Fitem%20%3FitemLabel%20%3Fstatement_count%0AWHERE%20%7B%0A%20%20%7B%0A%20%20%20%20SELECT%20%3Fitem%20%3Fstatement_count%0A%20%20%20%20WHERE%20%7B%0A%20%20%20%20%20%20%3Fitem%20wdt%3APproperty%20%5B%5D%20.%0A%20%20%20%20%20%20%3Fitem%20wikibase%3Astatements%20%3Fstatement_count%20.%0A%20%20%20%20%7D%0A%20%20%20%20ORDER%20BY%20DESC%20%28%3Fstatement_count%29%0A%20%20%20%20LIMIT%2010%0A%20%20%7D%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%7D%0A%0A" as ?query_template)
BIND (URI(REPLACE(?query_template,"property", STR(?propNumber))) as ?query_top_ten_items) #generate query URL by inserting property number into template

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } ORDER BY (?propNumber)

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Properties with 5 or less Model Item statements, with links to query for top 10 items using the property
SELECT ?property ?propertyLabel ?model_item_statement_count ?query_top_ten_items
WHERE {
  {
    SELECT DISTINCT ?property (COUNT(?modelItem) as ?model_item_statement_count)
    WHERE {
      ?property rdf:type wikibase:Property . #all properties
      OPTIONAL { ?property wdt:P5869 ?modelItem } #with model items if present
    } GROUP BY ?property 
  }

  FILTER (?model_item_statement_count < 5) #only show properties with 5 or less Model Item statements
  BIND (xsd:integer( SUBSTR(STR(?property), 33) ) as ?propNumber) #use property number as a basic rank for 'top' properties 
  BIND ("https://query.wikidata.org/embed.html#SELECT%20%3Fitem%20%3FitemLabel%20%3Fstatement_count%0AWHERE%20%7B%0A%20%20%7B%0A%20%20%20%20SELECT%20%3Fitem%20%3Fstatement_count%0A%20%20%20%20WHERE%20%7B%0A%20%20%20%20%20%20%3Fitem%20wdt%3APproperty%20%5B%5D%20.%0A%20%20%20%20%20%20%3Fitem%20wikibase%3Astatements%20%3Fstatement_count%20.%0A%20%20%20%20%7D%0A%20%20%20%20ORDER%20BY%20DESC%20%28%3Fstatement_count%29%0A%20%20%20%20LIMIT%2010%0A%20%20%7D%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%7D%0A%0A"
        as ?query_template)       
  BIND (URI(REPLACE(?query_template,"property", STR(?propNumber))) as ?query_top_ten_items) #generate query URL by inserting property number into template

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY (?propNumber)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?modelItem") v5("?model_item_statement_count"):::projected v5("?propNumber") v3("?property"):::projected v5("?query_template") v6("?query_top_ten_items"):::projected c6(["bd:serviceParam"]):::iri c3(["wikibase:Property"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["?model_item_statement_count < '5^^xsd:integer'"]] f0 --> v5 v3 --"a"--> c3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P5869".-> v4 end bind2[/"count(?modelItem)"/] v4 --o bind2 bind2 --as--o v5 bind3[/"http://www.w3.org/2001/XMLSchema#integer(substring(str(?property),'33^^xsd:integer'))"/] v3 --o bind3 bind3 --as--o v5 bind4[/"'https://query.wikidata.org/embed.html#SELECT%20%3Fitem%20%3FitemLabel%20%3Fstatement_count%0AWHERE%20%7B%0A%20%20%7B%0A%20%20%20%20SELECT%20%3Fitem%20%3Fstatement_count%0A%20%20%20%20WHERE%20%7B%0A%20%20%20%20%20%20%3Fitem%20wdt%3APproperty%20%5B%5D%20.%0A%20%20%20%20%20%20%3Fitem%20wikibase%3Astatements%20%3Fstatement_count%20.%0A%20%20%20%20%7D%0A%20%20%20%20ORDER%20BY%20DESC%20%28%3Fstatement_count%29%0A%20%20%20%20LIMIT%2010%0A%20%20%7D%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%7D%0A%0A'"/] bind4 --as--o v5 bind5[/"replace(?query_template,'property',str(?propNumber))"/] v5 --o bind5 v5 --o bind5 bind5 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end