I am trying to get alternative names of given names in WikiData with the following simple query:
PREFIX ps: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
CONSTRUCT {?s rdfs:label ?o}
WHERE { ?s ps:P31 wd:Q202444. ?s rdfs:label ?o}
LIMIT 1000
Initially, the query was much more complex, but I was getting time-outs on the public WikiData SPARQL endpoint. I decided to use Linked Data Fragments to offload some filtering from the server to the client.
$comunica-sparql "https://query.wikidata.org/bigdata/ldf" -f query > given_names.n3
Could not retrieve https://query.wikidata.org/bigdata/ldf?subject=http%3A%2F%2Fwww.wikidata.org%2Fentity%2FQ21147790&predicate=http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23label&page=3 (500: unknown error)
(where query is a file with the SPARQL query shown above). Unfortunately, the client tries to get output from the 3rd page, I am getting the error. Following the link in fact returns HTTP 500 error with
The link points to the 3rd page. It works if you try to go to the second page.
Is this a bug or a limitation of a service?
This is definitely a bug; the server does not fulfill the Triple Pattern Fragments specification if pagination does not work.
Related
I am not able to refer my sparql query to external rdf resources. I do not get any results. I am using Apache Fuseki. Could there be anything wrong in my settings? Thx.
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?title
FROM <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>
WHERE { ?s dc:title ?title .}
Not from within Fuseki where FROM/FROM NAMED refer to graphs in the dataset being queried. This is what most people want. Long ago, it did pull from the web but that wasn't popular.
It works from the command line.
I have a DBPedia resource as
http://dbpedia.org/page/London
.
I would like to get French page of http://dbpedia.org/page/London using SPARQL. I have noticed that I can retrieve this information through owl:sameAs.
I am trying to write this query on http://dbpedia.org/sparql endpoint to retrieve http://fr.dbpedia.org/page/Londres page:
prefix owl: <http://www.w3.org/2002/07/owl#>
select ?resource where {
?resource owl:sameAs "http://dbpedia.org/page/London"
FILTER strStarts (?resource, "http://fr.dbpedia.org")
In particular, I thought to use "strStarts" property, because I have read this document: http://www.w3.org/TR/sparql11-query/#func-strstarts.
This document says that "The STRSTARTS function corresponds to the XPath fn:starts-with function" and I thought to use this function to retrieve the triples that start with "http://fr.dbpedia.org".
But, from my query I don't get any result. Why?
What am I doing wrong here?
There are a few problems in your query. First, URIs are not strings, so you'd need to use <http://dbpedia.org/page/London> rather than "http://dbpedia.org/page/London". Second, that's the wrong URI for London. The resource is <http://dbpedia.org/resource/London>. (Yes, when you put that in a web browser, you get redirected to the …/page/London; that's not the URI of the resource, though.) The URI can be abbreviated as dbpedia:London on the public endpoint. Third, because URIs are not strings, you need to filter strstarts( str(?resource), … ), explicitly getting the string form of the URI. Thus:
select ?resource where {
?resource owl:sameAs dbpedia:London
filter strstarts(str(?resource), "http://fr.dbpedia.org")
}
SPARQL results
I tried to make this query on http://sparql.sindice.com/
PREFIX rev: <http://purl.org/stuff/rev#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE
{
?thing rdfs:label ?name .
?thing rev:hasReview ?review .
filter regex(str(?name), "harlem", "i")
} LIMIT 10
And it returns 504 Gateway Time-out
The server didn't respond in time.
What i'm doing wrong?
Thanks.
You made a query that was too hard for the endpoint to answer in a timely fashion hence why you got a timeout response. Note that there website states the following:
all queries are time and resource limited. notice that this means that
sometime you will get incomplete or even no results. If this is
happening often for you or you really want to run more complex queries
please contact us
Your query essentially selects a vast swathe of data and then makes the engine run a regular expression over ever possible value which is extremely slow.
I believe Sindice use Virtuoso as their SPARQL implementation so you can cheat and use Virtuoso specific full text query extension like so:
PREFIX rev: <http://purl.org/stuff/rev#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE
{
?thing rdfs:label ?name .
?thing rev:hasReview ?review .
?name bif:contains "harlem" .
}
LIMIT 10
However this query also seems to timeout, if you can add more conditions to constrain your query further you will have more chance of getting results in a timely fashion.
I am trying to retrieve the value of the dbpedia-owl:influenced in this page e.g: Andy_Warhol
The query I write is:
PREFIX rsc : http://dbpedia.org/resource
PREFIX dbpedia-owl :http://dbpedia.org/ontology
SELECT ?o WHERE {
rsc:Andy_Warhol dbpedia-owl:infuenced ?o .
}
but it is EMPTY.
Strange is that when I have the same query for another property from the ontology type like "birthPlace", the sparql engine gives the result back:
SELECT ?o WHERE {
rsc:Andy_Warhol dbpedia-owl:birthplace ?o .
}
which is a link to another resource:
dbpedia.org/resource/Pittsburgh
I am just confused how to write this query?
besides several formal errors addressed in the answer of #Joshua, there is also the semantic problem that the properties you are looking for - in this case - seem to be found on the entities that were influenced.
this query might give you the desired results
PREFIX rsc: <http://dbpedia.org/resource/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT ?s WHERE {
?s dbpedia-owl:influencedBy rsc:Andy_Warhol .
}
run query
There are a few issues here. One is that the SPARQL, as presented, isn't correct. I edited to make the prefix syntax legal, but the prefixes were still wrong (they didn't end with a final slash). You don't want to be querying for http://dbpedia.org/resourceAndy_Warhol after all; you want to query for http://dbpedia.org/resource/Andy_Warhol. Some standard namespaces for DBpedia are listed on their SPARQL endpoint. Using those namespaces and the SPARQL endpoint, we can ask for all the triples that have http://dbpedia.org/resource/Andy_Warhol as the subject with this query:
SELECT * WHERE {
dbpedia:Andy_Warhol ?p ?o .
}
In the results produced there, you'll see the one using http://dbpedia.org/ontology/birthPlace (note the captial P in birthPlace), but you won't see any triples with the predicate http://dbpedia.org/ontology/infuenced, so it makes sense that your first query has no results. Do you have some reason to suppose that there should be some results?
I am having trouble executing SPARQL queries against dbpedia.org using Jena.
The queries are of the form:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX p: <http://dbpedia.org/property/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?album ?name ?dateofrelease
WHERE {
?album p:artist <http://dbpedia.org/resource/SomeArtist> .
?album rdf:type <http://dbpedia.org/ontology/Album> .
?album rdf:type <http://schema.org/MusicAlbum> .
?album p:name ?name .
?album <http://dbpedia.org/ontology/releaseDate> ?dateofrelease .
FILTER(xsd:dateTime(?dateofrelease) >= '2009-01-01T00:00:00Z'^^xsd:dateTime)
} LIMIT 5
where http://www.dbpedia.org/resource/SomeArtist is a valid artist URI, e.g. http://dbpedia.org/resource/Wilco, and URL-encoded properly before sent.
The queries are executed with the following standard code:
Query query = QueryFactory.create(queryString);
QueryExecution qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
ResultSet results = queryExecution.execSelect();
The program is doing about 30 queries on the same form, but some of them "hangs" for about a minute or two before Jena throws a
com.hp.hpl.jena.sparql.resultset.ResultSetException: Not an ResultSet result
If I catch the exception and go on, some queries hang and some returns a result set quickly with either 0 or more results. Doing this several times, it's random what queries that returns or "hangs". Using the SPARQL DBpedia with a identical query sometimes works, sometimes hangs in the same way in the web browser.
Am I constructing the query wrong, making it in some way time consuming for dbpedia.org so that the query timeout at the sever? I'm quite new to the Semantic Web and Jena, but I thought initially my query not could be very time consuming since I'm using a absolute URI for the object part in the
?album p:artist <http://www.dbpedia.org/resource/SomeArtist>
statement.
Is there some number of requests from-one-source/per-time-unit limit to dbpedia.org that I'm not aware of?
(Using Jena 2.6.4)
I can confirm that the query is slow.
I tried a few variations that might effect the speed, but it didn't help. I can't see any obvious reason why that type of query would be particularly slow, sorry.
One alternative, to get more consistent response times would be to download the DBPedia dump, grep out the predicates that you're interested in, and load them into a local triplestore, e.g. Jena.