I am trying to make a fuzzy (i.e., incomplete or case insensitive) search for an entity label in Wikidata with Sparql (via an online endpoint). Unfortunately, they return a "QueryTimeoutException: the request has expired." I assume this is because the query returns too many results to skip the filter after 1 minute of the Wikidata timeout.
Here is a specific request:
def findByFuzzyLabel(self, item_label):
qstring = '''
SELECT ?item WHERE {
?item rdfs:label ?label .
FILTER( lcase(str(?label)) = "%s")
}
LIMIT 20
''' % (item_label)
results = self.query(qstring)
Is there a way to make a partial search by lines and / or insensitive to labels on Wikidata entity labels or do I need to do this offline when loading raw data?
I am looking for suitable shortcuts, such as Lindbergh, for Charles Lindbergh, and in some cases case insensitivity. Any suggestions on how to do this, whether through Sparql or offline in Python, are appreciated.
source
share