This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
queries.py
44 lines (40 loc) · 1.49 KB
/
queries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
wikidataSparqlEndpoint = "https://query.wikidata.org/bigdata/namespace/wdq/sparql"
userAgent = 'PhysicsNobel (federico.bertani@studio.unibo.it)'
# TODO optimize queries on searching on instance and sublass of humans
allLaureate = """
SELECT ?itemLabel (YEAR(?date) as ?year) ?picture WHERE {
?item p:P166 ?statement.
?statement ps:P166 wd:Q38104.
?statement pq:P585 ?date
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
}
OPTIONAL { ?item wdt:P18 ?picture. }
}
"""
# TODO find alternative to use group by
laureateDetail = """
SELECT ?itemLabel (YEAR(?date) as ?year) ?picture WHERE {{
?item ?label "{0}"@en.
?item p:P166 ?statement.
?statement ps:P166 wd:Q38104.
?statement pq:P585 ?date
SERVICE wikibase:label {{
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
}}
OPTIONAL {{
?item wdt:P18 ?picture.
}}
}}
GROUP BY ?date ?itemLabel ?picture
"""
allPrizes = """
SELECT (YEAR(?date) as ?year) ?itemLabel WHERE {
?item p:P166 ?statement.
?statement ps:P166 wd:Q38104.
?statement pq:P585 ?date
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
}
}
"""