Skip to content

Commit

Permalink
Handle statements about redirects in SPARQL queries
Browse files Browse the repository at this point in the history
  • Loading branch information
dseomn committed Mar 4, 2024
1 parent 3ff13d9 commit 901a750
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rock_paper_sand/wikidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def transitive_subclasses(
subclass_of = wikidata_value.P_SUBCLASS_OF.id
results = self.sparql(
"SELECT REDUCED ?class WHERE { "
f"?class wdt:{subclass_of}* wd:{class_ref.id}. "
f"?class (wdt:{subclass_of}|owl:sameAs)* wd:{class_ref.id}. "
"?class wikibase:sitelinks []. "
"}"
)
Expand Down Expand Up @@ -255,13 +255,15 @@ def related_media(self, item_ref: wikidata_value.ItemRef) -> RelatedMedia:
" UNION ".join(
(
"{ "
f"wd:{item_ref.id} ({predicate}) ?item. "
f"wd:{item_ref.id} "
f"^owl:sameAs?/({predicate})/owl:sameAs? ?item. "
f'BIND ("{relation}" AS ?relation) '
"}"
)
for relation, predicate in predicate_by_relation.items()
),
"FILTER (!wikibase:isSomeValue(?item))",
"FILTER NOT EXISTS { ?item owl:sameAs ?other }",
f"OPTIONAL {{ ?item wdt:{instance_of} ?class. }}",
f"OPTIONAL {{ ?item wdt:{form} ?form. }}",
"}",
Expand Down

0 comments on commit 901a750

Please sign in to comment.