Allow import of query_materials

main
Gijs 2 years ago
parent 6f14f9a5db
commit 2c4f2f9db3

@ -0,0 +1,27 @@
from query_materials import get_info, query
from time import sleep
q1 = """
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
SELECT DISTINCT ?item ?itemLabel WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
{
SELECT DISTINCT ?item WHERE {
?item p:P1343 ?statement0.
?statement0 (ps:P1343/(wdt:P279*)) wd:Q19219752.
?item p:P31 ?statement1.
?statement1 (ps:P31/(wdt:P279*)) wd:Q16521.
?item p:P4000 ?statement2.
?statement2 (ps:P4000/(wdt:P279*)) wd:Q5118786.
}
LIMIT 100
}
}
"""
for result in query(q1):
info = get_info(result['item']['value'])
print('A ' + info['labels']['en']['value'] + ' IS KNOWN IN DUTCH AS ' + info['labels']['nl']['value'])
print('A ' + info['labels']['en']['value'] + ' TREE')
sleep(1)

@ -38,22 +38,22 @@ SELECT DISTINCT ?item ?statement0 ?material WHERE
LIMIT 10
"""
print (q1)
print ()
from time import sleep
for result in query(q1):
statement = result['statement0']['value']
value, item = result['material']['value'], result['item']['value']
value = get_info(value)
item = get_info(item)
# print ("value", value)
# print ("item", item)
try:
material_label, item_label = value['labels']['en']['value'], item['labels']['en']['value']
print (f"A {item_label} made of {material_label}. See {statement}")
print ()
sleep(3)
except KeyError:
print ("no english label?")
if __name__ == '__main__':
print (q1)
print ()
from time import sleep
for result in query(q1):
statement = result['statement0']['value']
value, item = result['material']['value'], result['item']['value']
value = get_info(value)
item = get_info(item)
# print ("value", value)
# print ("item", item)
try:
material_label, item_label = value['labels']['en']['value'], item['labels']['en']['value']
print (f"A {item_label} made of {material_label}. See {statement}")
print ()
sleep(3)
except KeyError:
print ("no english label?")
Loading…
Cancel
Save