query-4d3ad53819bab543f78bad15320d0a0a

rq turtle/ttl

Query that locates categories with most interwikis that still don't have a corresponding category on HebwikiI attempted to create a query on Wikidata that would help identify the categories with the most interwiki links which still don't have a corresponding article at the Hebrew Wikipedia (hoping that by doing this I would be able to create some of the most popular categories at Wikipedia which haven't been created yet on the Hebrew Wikipedia). Unfortunately, the query keeps timing out. This is what I have created so far:

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 bd: <http://www.bigdata.com/rdf#>
SELECT ?category ?categoryLabel (COUNT(DISTINCT ?item) AS ?sitelinkCount) 
WHERE {
  ?category wdt:P31 wd:Q4167836;        # Select categories
            schema:about ?item.         # Category is about an item

  # Ensure the item has a sitelink to English Wikipedia
  ?item schema:isPartOf <https://en.wikipedia.org/>.

  # Filter out categories with Hebrew Wikipedia sitelinks
  FILTER NOT EXISTS {
    ?item schema:isPartOf <https://he.wikipedia.org/>.
  }

  # Retrieve category labels in English
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?category ?categoryLabel
HAVING (COUNT(DISTINCT ?item) > 50)     # Filter for categories with more than 50 items
ORDER BY DESC(?sitelinkCount)
LIMIT 50                                # Lower limit to avoid timeout

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?_anon_42b5416610844a34809f33a099ae9de174273") v3("?category"):::projected v2("?item"):::projected v5("?sitelinkCount") a1((" ")) c7([https://en.wikipedia.org/]):::iri c3([https://he.wikipedia.org/]):::iri c9(["bd:serviceParam"]):::iri c11(["en"]):::literal c5(["wd:Q4167836"]):::iri f0[[" > '50^^xsd:integer'"]] f0 --> a1 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 --"schema:isPartOf"--> e0c2 e0v1("?item"):::projected e0c2([https://he.wikipedia.org/]):::iri end f1--EXISTS--> f1e0 f1 --> v2 f1 --> c2 f1 --> c3 v2 --"schema:isPartOf"--> c3 v3 --"wdt:P31"--> c5 v3 --"schema:about"--> v2 v2 --"schema:isPartOf"--> c7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end bind4[/"count(?item)"/] v2 --o bind4 bind4 --as--o v4 bind5[/"count(?item)"/] v2 --o bind5 bind5 --as--o v5