From: Visser, D. <dv...@id...> - 2013-08-16 15:08:19
|
Mariano: There is a period after the first URI in the graph pattern, which is only supposed to come after a complete triple pattern: u"\n SELECT * WHERE {\n <http://dbpedia.org/resource/Tim_Cook>.\n ?x dbpedia-owl:abstract ?abstract.\n OPTIONAL { ?x dbpedia-owl:birthDate ?birthDate. OPTIONAL { ?x dbpedia-owl:birthPlace ?birthPlace. OPTIONAL { ?x dbpprop:name ?name. OPTIONAL { ?x dbpedia-owl:profession ?profession. OPTIONAL { ?x dbpprop:residence ?residence. OPTIONAL { ?x dbpprop:website ?website.\n FILTER (LANG(?abstract) = 'en')\n }\n " Best regards, Dale Visser From: Mariano Alvarez [mailto:ro...@li...] Sent: Friday, August 16, 2013 10:20 AM To: spa...@li... Subject: [sparql-wrapper-devel] Query bad formed I'm trying to build a sparql query based on a list of properties but I get an error saying that the query is bad formed. The problem is I don't know what to do to fix it. This is the function: def create_query(dbpedia_uri, props): #props are something like this ('dbpedia-owl', 'birthdate') filters = '' for prop in QUERIES_DICT[ename]: filters += ' OPTIONAL { ?x %s:%s ?%s.' % (corresp_dict[prop[0]], prop[1], prop[1]) query = u""" SELECT * WHERE { . <%s>. ?x dbpedia-owl:abstract ?abstract. %s FILTER (LANG(?abstract) = 'en') } """ % (dbpedia_uri, filters) return query This is the query I get: u"\n SELECT * WHERE {\n <http://dbpedia.org/resource/Tim_Cook>.\n ?x dbpedia-owl:abstract ?abstract.\n OPTIONAL { ?x dbpedia-owl:birthDate ?birthDate. OPTIONAL { ?x dbpedia-owl:birthPlace ?birthPlace. OPTIONAL { ?x dbpprop:name ?name. OPTIONAL { ?x dbpedia-owl:profession ?profession. OPTIONAL { ?x dbpprop:residence ?residence. OPTIONAL { ?x dbpprop:website ?website.\n FILTER (LANG(?abstract) = 'en')\n }\n " |