Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPARQL query parsing error #3

Open
oktie opened this issue Oct 13, 2015 · 0 comments
Open

SPARQL query parsing error #3

oktie opened this issue Oct 13, 2015 · 0 comments

Comments

@oktie
Copy link
Owner

oktie commented Oct 13, 2015

Copied from Google Code: https://code.google.com/p/linkedct/issues/detail?id=2

Error reported by Paul Webster.

http://linkedct.org/sparql?query=SELECT+*%0D%0AWHERE+{+%3Fs+%3Fp+%3Fo.}%0D%0ALIMIT+10
will work

but

http://linkedct.org/sparql?query=SELECT+*%0D%0AWHERE+{+%3Fs+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23type%3E+%3Fo.}%0D%0ALIMIT+10
will generate an error

More from Paul:

Example 1 works - (doesn't convert to json, but not the biggest

problem in the world)##
from SPARQLWrapper import SPARQLWrapper, JSON

sparql = SPARQLWrapper("http://linkedct.org/sparql")
sparql.setQuery("""
SELECT *
WHERE { ?s ?p ?o.}
LIMIT 10
""")
sparql.setReturnFormat("json")
results = sparql.query().convert()

print results

Example 2 doesn't work - fails with an error (incidentally if I

replace "rdf:type" with "a" and omit the prefix it works, but if I
omit the prefix and expand rdf:type to
http://www.w3.org/1999/02/22-rdf-syntax-ns#type it fails with the
same error message)##
from SPARQLWrapper import SPARQLWrapper, JSON

sparql = SPARQLWrapper("http://linkedct.org/sparql")
sparql.setQuery("""
PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
SELECT *
WHERE { ?s rdf:type ?o.}
LIMIT 10
""")
sparql.setReturnFormat("json")
results = sparql.query().convert()

print results

Error Message

<title>Error 400 Parse error:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns

Encountered " "<" "< "" at line 2, column 17.
Was expecting:
<IRIref> ...

</title>

Looks like a parsing issue when the query contains '<' or '>'.

Jan 23, 2012
#1 rjhoekstr

I am experiencing the same problem. This essentially means that the SPARQL endpoint is pointless. Should be an easy fix. Resorting to data dumps is not really an option as well, as the last dump is already quite old (was of May 2011).

Feb 8, 2012
Project Member #3 oktie@oktie.com

  1. I just uploaded a new data dump. http://queens.db.toronto.edu/~oktie/linkedct/ will try to put up new dumps more frequently. Please feel free to email me if you need a fresh dump at any time (it takes less than an hour to generate a new dump).

  2. The SPARQL endpoint is not pointless. There are still many queries you can run, but I understand this issue needs to be fixed.

On the other hand, I just noticed that there is a more serious issue that could really limit the types of queries you can run. Here is a temporary way around the problem, until I find more time to find out why this has happened (I believe it has to do with moving to a new server which happend less than a month ago): replace "data.linkedct.org" in the URIs with "128.100.3.150:2020".

For example, to query for a list of trials, instead of:
http://data.linkedct.org/sparql?query=SELECT * WHERE { ?trial a http://data.linkedct.org/vocab/resource/trial . }
try:
http://data.linkedct.org/sparql?query=SELECT * WHERE { ?trial a <http://128.100.3.150:2020/vocab/resource/trial . }

Feb 9, 2012
#4 codehop.dev

Hi,

I took the latest data dump (2/8/12) and loaded into a virtuoso server. The SPARQL interface is here: http://dbmi-icode-01.dbmi.pitt.edu:8080/sparql

Please be sure to use the default IRI: http://data.linkedct.org/

Tested with the following query:

lctSparql = SPARQLWrapper("http://dbmi-icode-01.dbmi.pitt.edu:8080/sparql")
lctSparql.addDefaultGraph("http://data.linkedct.org/")
lctSparql.setQuery("""
PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
SELECT *
WHERE { ?s rdf:type ?o.}
LIMIT 100
""")

lctSparql.setReturnFormat("json")
results = lctSparql.query().convert()
print results

Feb 11, 2012
#5 codehop.dev

Just an update to comment 4 regarding the "mirror" of linkedCT I set up - for now there is a problem with the URIs returned by the server. Apparently, the data dump I used did not have include the '/resource' in the http://data.linkedct.org/ URIs. This is corrected in the latest dump ( http://queens.db.toronto.edu/~oktie/linkedct/ ); I will mirror the change by March 1 unless someone needs it sooner. In the meantime, I simply add it by parsing the URIs as follows (in Python):

.replace("/trial/", "/resource/trial/"),
.replace("/reference/", "/resource/reference/")
.replace("//", "/resource//")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant