query-8b24fbe3fc2c7dc4bb8ab22c08c2bf20

rq turtle/ttl

title: Languages with count per usage example and count per usage examples that have pronunciation audio.

SELECT ?lang ?langLabel ?langCode ?count ?countAudios

Get all languages that has at least one lexeme in Wikidata

WITH { SELECT DISTINCT ?lang ?langCode { [] dct:language ?lang. ?lang wdt:P424 ?langCode. } } AS %0

Get all examples along with their language code and the claim

identifiers of those statements

WITH { SELECT ?claim ?example ?langCode { [] p:P5831 ?claim. ?claim ps:P5831 ?example. BIND(LANG(?example) AS ?langCode) } } AS %1

Get count of examples per language

WITH { SELECT ?langCode (COUNT(*) AS ?count) { INCLUDE %1. } GROUP BY ?langCode } AS %2

Get count of examples that have pronunciation audio per language

WITH { SELECT ?langCode (COUNT(*) AS ?countAudios) { INCLUDE %1. ?claim pq:P443 []. } GROUP BY ?langCode } AS %3 { # OPTIONAL is used so that rows that are shown by some INCLUDE but # not by other INCLUDE are still shown in the results. Thus, for # example, we can know which languages have 0 pronunciation audios # or which language code is not linked to a Wikidata item.

OPTIONAL{INCLUDE %0} OPTIONAL{INCLUDE %2} OPTIONAL{INCLUDE %3} SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } ORDER BY DESC(?countAudios) DESC(?count)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title: Languages with count per usage example and count per usage examples that have pronunciation audio.

SELECT
  ?lang
  ?langLabel
  ?langCode
  ?count
  ?countAudios
# Get all languages that has at least one lexeme in Wikidata
# Get all examples along with their language code and the claim
# identifiers of those statements
# Get count of examples per language
# Get count of examples that have pronunciation audio per language
{
  # OPTIONAL is used so that rows that are shown by some INCLUDE but
  # not by other INCLUDE are still shown in the results. Thus, for
  # example, we can know which languages have 0 pronunciation audios
  # or which language code is not linked to a Wikidata item.

  OPTIONAL{ {
  SELECT DISTINCT ?lang ?langCode {
    [] dct:language ?lang.
    ?lang wdt:P424 ?langCode.
  }
}}
  OPTIONAL{ {
  SELECT ?langCode (COUNT(*) AS ?count) {
     {
  SELECT ?claim ?example ?langCode {
    [] p:P5831 ?claim.
    ?claim ps:P5831 ?example.
    BIND(LANG(?example) AS ?langCode)
  }
}
  }
  GROUP BY ?langCode
}}
  OPTIONAL{ {
  SELECT ?langCode (COUNT(*) AS ?countAudios) {
     {
  SELECT ?claim ?example ?langCode {
    [] p:P5831 ?claim.
    ?claim ps:P5831 ?example.
    BIND(LANG(?example) AS ?langCode)
  }
}
    ?claim pq:P443 [].
  }
  GROUP BY ?langCode
}}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY DESC(?countAudios) DESC(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?claim") v7("?count"):::projected v7("?countAudios"):::projected v6("?example") v3("?lang"):::projected v7("?langCode"):::projected a1((" ")) a2((" ")) a3((" ")) a4((" ")) c7(["bd:serviceParam"]):::iri c9(["en"]):::literal subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; a1 -."dct:language".-> v3 v3 --"p:direct/P424"--> v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; a2 -."p:P5831".-> v5 v5 --"p:statement/P5831"--> v6 bind0[/"?example"/] v6 --o bind0 bind0 --as--o v7 bind2[/"count(*)"/] bind2 --as--o v7 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; a3 -."p:P5831".-> v5 v5 --"p:statement/P5831"--> v6 bind3[/"?example"/] v6 --o bind3 bind3 --as--o v7 v5 --"p:qualifier/P443"--> a4 bind5[/"count(*)"/] bind5 --as--o v7 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end