From 63f8d0f580c4a47406294b63fc77b50e2db687dc Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 31 Dec 2019 09:01:20 +0000 Subject: [PATCH] Add missing changes for catching non-artwork. --- depicts/wdqs.py | 6 ++++++ templates/query/item_type.sparql | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 templates/query/item_type.sparql diff --git a/depicts/wdqs.py b/depicts/wdqs.py index a966a72..9da2b1a 100644 --- a/depicts/wdqs.py +++ b/depicts/wdqs.py @@ -202,3 +202,9 @@ def quote_list(l): def url_list(l): no_dups = list(dict.fromkeys(l)) # remove duplicates return ' '.join(f'(<{s}>)' for s in no_dups) + +def is_artificial_physical_object(qid): + bindings = run_from_template_with_cache('query/item_type.sparql', qid=qid) + types = {row_id(row, field='item') for row in bindings} + # Q8205328 == artificial physical object + return 8205328 in types diff --git a/templates/query/item_type.sparql b/templates/query/item_type.sparql new file mode 100644 index 0000000..443c3ee --- /dev/null +++ b/templates/query/item_type.sparql @@ -0,0 +1,4 @@ +select ?item ?itemLabel { + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } + wd:{{ qid }} wdt:P31/wdt:P279* ?item . +}