From 25543fa8cd3b5c60cc8c7ec06443f09d1a45d4b8 Mon Sep 17 00:00:00 2001 From: Adriano Rutz Date: Wed, 22 Nov 2023 22:00:49 +0100 Subject: [PATCH] Allow use of Qlever endpoint --- update/common.py | 5 +++-- update/download_taxonomy_parenting.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/update/common.py b/update/common.py index dce0339..31c794c 100644 --- a/update/common.py +++ b/update/common.py @@ -1,11 +1,12 @@ import requests WD_URL = "https://query.wikidata.org/sparql" +QLEVER_URL = "https://qlever.cs.uni-freiburg.de/api/wikidata" -def wd_sparql_to_csv(query: str) -> str: +def wd_sparql_to_csv(query: str, url: str = WD_URL) -> str: return requests.get( - WD_URL, params={"query": query}, headers={"Accept": "text/csv"} + url, params={"query": query}, headers={"Accept": "text/csv"} ).text diff --git a/update/download_taxonomy_parenting.py b/update/download_taxonomy_parenting.py index 6f20afe..9ad635c 100644 --- a/update/download_taxonomy_parenting.py +++ b/update/download_taxonomy_parenting.py @@ -3,7 +3,7 @@ from io import StringIO from pathlib import Path -from update.common import remove_wd_entity_prefix, wd_sparql_to_csv +from update.common import remove_wd_entity_prefix, wd_sparql_to_csv, QLEVER_URL query_taxa = """ SELECT DISTINCT ?taxon ?taxon_name ?taxon_rank ?parent WITH {