-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgems.py
84 lines (78 loc) · 1.81 KB
/
gems.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#PERSON QUERIES#
# spouse
spouse_query = """SELECT ?info
WHERE
{{
?subject wdt:P26 ?object .
?object rdfs:label ?name .
?subject rdfs:label ?info .
?subject wdt:P27 wd:Q739
FILTER (regex(?name, "{}","i"))
}} LIMIT 1"""
# political party filiations
political_party_query = """SELECT DISTINCT ?info
WHERE
{{
?subject rdfs:label ?name .
?subject wdt:P102 ?object .
?object rdfs:label ?info .
?subject wdt:P27 wd:Q739
FILTER (regex(?name, "{}","i"))
FILTER ( lang(?info) = "es" )
}}"""
# education
education_query = """SELECT DISTINCT ?info
WHERE
{{
?subject rdfs:label ?name .
?subject wdt:P69 ?object .
?object rdfs:label ?info .
?subject wdt:P27 wd:Q739 .
FILTER (regex(?name, "{}","i"))
FILTER ( lang(?info) = "es" )
}}"""
# place of birth
place_of_birth_query = """SELECT DISTINCT ?info
WHERE
{{
?subject rdfs:label ?name .
?subject wdt:P19 ?object .
?object rdfs:label ?info .
?subject wdt:P27 wd:Q739 .
FILTER (regex(?name, "{}","i"))
FILTER ( lang(?info) = "es" )
}} LIMIT 1"""
# positions held
positions_held_query = """SELECT DISTINCT ?info
WHERE
{{
?subject rdfs:label ?name .
?subject wdt:P39 ?object .
?object rdfs:label ?info .
?subject wdt:P27 wd:Q739 .
FILTER (regex(?name, "{}","i"))
FILTER ( lang(?info) = "es" )
}}"""
#ORGANIZATION QUERIES#
# CEO query
ceo_query = """
PREFIX esdbp: <http://es.dbpedia.org/property/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?ceoUri
WHERE
{{
?s rdfs:label ?label .
?s esdbp:keyPeople ?ceoUri .
?s dbo:location <http://es.dbpedia.org/resource/Colombia> .
FILTER (regex(?label, "{}","i"))
FILTER (lang(?label) = 'es')
}}"""
# CEO name query
ceo_name_query = """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?ceoName
WHERE
{{
<{}> foaf:name ?ceoName
}}"""