User:Bovlb/queries
Jump to navigation
Jump to search
Try it!
Try it!
Try it!
Try it!
Some WDQ queries I wanted to save:
Uses of anonymous
[edit]SELECT ?x ?xLabel ?xDescription ?p ?pLabel ?pDescription
WHERE {
?x ?wdt wd:Q4233718 .
?p wikibase:directClaim ?wdt .
FILTER(?p != wd:P31)
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
Shared identifiers
[edit]SELECT ?x ?xLabel ?xDescription ?id ?y ?yLabel ?yDescription WHERE {
?x wdt:P1153 ?id .
?y wdt:P1153 ?id .
FILTER(STR(?x) < STR(?y))
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
Notability
[edit]SELECT ?x ?exists
?notability1_strong ?notability2a_strong ?notability2b_strong ?notability3_strong ?notability_strong
?notability1_weak ?notability2a_weak ?notability2b_weak ?notability3_weak ?notability_weak
?xLabel ?xDescription WHERE {
VALUES ?x {wd:Q42 wd:Q48507154 wd:Q113547783 wd:Q107204561 wd:Q113547694 wd:Q113548247 wd:Q113548224 wd:Q113551800 wd:Q108218763 wd:Q58409749}
BIND(exists {
?x schema:version ?version .
} AS ?exists)
# N1: It contains at least one valid sitelink ...
BIND(EXISTS { # ?notability1_strong
?sitelink schema:about ?x .
} AS ?notability1_strong)
BIND(?notability1_strong as ?notability1_weak) # FUTURE
# N2a: It refers to an instance of a clearly identifiable conceptual or material entity
BIND(EXISTS { # ?notability2a_weak
{
?x ?p ?statement .
?prop wikibase:claim ?p .
?prop wikibase:propertyType <http://wikiba.se/ontology#ExternalId> .
} UNION {
?x p:P856 ?statement . # official website
}
} AS ?notability2a_weak)
BIND(EXISTS { # ?notability2a_strong
{
?x ?p ?statement .
?prop wikibase:claim ?p .
?prop wikibase:propertyType <http://wikiba.se/ontology#ExternalId> .
} MINUS {
?prop wdt:P279*/wdt:P31 wd:Q105388954 . # Wikidata property to identify online accounts
}
} AS ?notability2a_strong)
#N2b: The entity must be notable, in the sense that it can be described using serious and publicly available references.
BIND(EXISTS { # ?notability2b_weak
{
?x ?p ?statement .
?statement prov:wasDerivedFrom ?ref .
} UNION {
?x ?p ?statement .
?prop wikibase:claim ?p .
?prop wdt:Q31 wd:Q62589316 . # Wikidata property for an identifier that suggests notability
} UNION {
?x p:P973 ?statement . # described at URL
}
} AS ?notability2b_weak)
BIND(EXISTS { # ?notability2b_strong
{
{
?x ?p ?statement .
?statement prov:wasDerivedFrom ?ref .
} MINUS {
?ref ?pr ?source .
?prop wikibase:reference ?pr .
?prop wdt:P31 wd:Q113558322 . # Wikidata property that suggests a reference is weak
}
} UNION {
?x ?p ?statement .
?prop wikibase:claim ?p .
?prop wdt:Q31 wd:Q62589316 . # Wikidata property for an identifier that suggests notability
} UNION {
?x p:P973 ?statement . # described at URL
}
} AS ?notability2b_strong)
# N3: It fulfills a structural need, for example: it is needed to make statements made in other items more useful.
BIND(EXISTS { # ?notability3_strong
?statement ?ps ?x .
?other ?p ?statement .
?prop wikibase:claim ?p .
FILTER(?other != ?x)
} AS ?notability3_strong)
BIND(?notability3_strong as ?notability3_weak) # FUTURE
BIND((?notability1_strong|| (?notability2a_strong && ?notability2b_strong) || ?notability3_strong) AS ?notability_strong)
BIND((?notability1_weak || (?notability2a_weak && ?notability2b_weak) || ?notability3_weak) AS ?notability_weak)
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
Empty items
[edit]SELECT ?x ?xLabel ?xDescription ?dateModified WHERE {
# Dexbot tries to process empty items after about 72 hours, so look for cases it missed.
BIND(NOW() + "-P7D"^^xsd:duration AS ?end) # Untouched in a week
?x
wikibase:statements "0"^^xsd:integer ;
wikibase:sitelinks "0"^^xsd:integer ;
wikibase:identifiers "0"^^xsd:integer ;
schema:dateModified ?dateModified .
FILTER(?dateModified < ?end)
FILTER NOT EXISTS { ?y ?p ?x . ?prop wikibase:directClaim ?p . }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
} ORDER BY DESC(?dateModified) LIMIT 100