-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqa_counts.py
101 lines (73 loc) · 1.98 KB
/
qa_counts.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import json
import sys
import csv
import requests
datascape_actors = json.load(open('data/actors.json'))
SPARQL_ENDPOINT = 'https://query.semlab.io/proxy/wdqs/bigdata/namespace/wdq/sparql'
total_created=0
total_recon = 0
for d in datascape_actors:
qid = datascape_actors[d]['BaseQidCheck']
sparql = f"""
SELECT ?project
WHERE
{{
wd:{qid} wdt:P11 ?project.
}}
"""
headers = {
'Accept': 'application/sparql-results+json',
}
params = {
'query' : sparql
}
response = requests.get(
SPARQL_ENDPOINT,
params=params,
headers=headers,
)
has_datascape_project = False
has_eat_project = False
if 'Q27735' in response.text:
has_datascape_project = True
if 'Q19104' in response.text:
has_eat_project = True
if has_datascape_project == False:
total_recon=total_recon+1
elif has_datascape_project == True and has_eat_project == True:
total_created=total_created+1
else:
print(qid, 'some thing werid')
print('total_recon',total_recon,'total_created',total_created)
# # get the labels for everything
# sparql = f"""
# select * where{{
# ?item wdt:P245 "actor/{d}".
# }}
# """
# headers = {
# 'Accept': 'application/sparql-results+json',
# }
# params = {
# 'query' : sparql
# }
# response = requests.get(
# SPARQL_ENDPOINT,
# params=params,
# headers=headers,
# )
# data = response.json()
# print(f"actor/{d}", len(data['results']['bindings']))
# if len(data['results']['bindings']) == 1:
# qid = data['results']['bindings'][0]['item']['value'].split('/')[-1]
# if qid in usedQids:
# print("Qid used twice", datascape_actors[d], qid)
# usedQids.append(qid)
# datascape_actors[d]['BaseQidCheck'] = qid
# elif len(data['results']['bindings']) > 1:
# print('Multiple Datascape Id Found:')
# print(datascape_actors[d])
# else:
# print('DATASCAPE Id Not Found:')
# print(datascape_actors[d])
# json.dump(datascape_actors,open('data/actors.json','w'),indent=2)