I made a function that executes a SPARQL query on the DBpedia SPARQL endpoint. This function takes an array of 15 elements, and each time it substitutes an element from the array into the query, then executes it to get result. The problem is that it takes the first 9 elements then this error is raised:
results = sparql.query().convert()
File "build/bdist.linux-i686/egg/SPARQLWrapper/Wrapper.py", line 390, in query
return QueryResult(self._query())
File "build/bdist.linux-i686/egg/SPARQLWrapper/Wrapper.py", line 369, in _query
raise e
HTTPError: HTTP Error 414: Request-URI Too Large
My query is as follows:
sparql = SPARQLWrapper('http://mlode.nlp2rdf.org/sparql');
querystring="""
PREFIX dc:<http://purl.org/dc/elements/1.1/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX olia-ar: <http://purl.org/olia/arabic_khoja.owl#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX lexvo: <http://lexvo.org/id/iso639-3/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX gold: <http://purl.org/linguistics/gold/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX qvoc: <http://www.nlp2rdf.org/quranvocab#>
SELECT ?verseTextAr ?tafseer
WHERE
{
?verse a qvoc:Verse;
qvoc:chapterIndex 26;
qvoc:verseIndex WORD;
skos:prefLabel ?verseTextAr;
qvoc:descByJalalayn ?tafseer.
}
"""
The 414 error means that SPARQLWrapper is trying to do a HTTP GET
for the query but the query is too large resulting in a request URI that the DBPedia servers reject.
You need to get SPARQLWrapper to POST
the query instead, the documentation states that this is possible and it appears that the setMethod()
method should be used to configure this.