我创建了一个在DBpedia SPARQL端点上执行SPARQL查询的函数。此函数采用15个元素的数组,每次将数组中的元素替换为查询,然后执行它以获得结果。问题是它需要前9个元素然后引发此错误:
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
我的查询如下:
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.
}
"""
答案 0 :(得分:3)
414错误意味着SPARQLWrapper正在尝试为查询执行HTTP GET
,但查询过大导致DBPedia服务器拒绝的请求URI。
您需要将SPARQLWrapper改为POST
查询,而documentation表明这是可能的,并且似乎应该使用setMethod()
方法来配置它。