Why dbpedia result is not consistant - sparql

I'm executing the below SPARQL query
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?resource WHERE {
?resource a <http://dbpedia.org/ontology/Place> .
{?resource rdfs:label 'Paris'#en.} UNION { ?resource rdfs:label 'France'#en.}
}
I'm executing this here.
Sometimes I am getting required result and sometimes it returns 502 error ( I get the message that website is under maintenance.....)
Can you please let me know why result is not consistent and how can I avoid this?
Also inconsistent behavior when I execute through java code :
Query query = QueryFactory.create(sb.toString());
QueryExecution qexec =
QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);

The experimental DBpedia SPARQL endpoint is made available as a public service, but as such it has no Quality-of-Service (QoS) guarantees.
You can set up your own DBpedia mirror in the Amazon AWS cloud, by spinning up the pre-populated and dynamically updated AMI. You can also set up a local mirror, by manually loading the DBpedia datasets into your own Virtuoso or other triple or quad store instance.
(ObDisclaimer: OpenLink Software produces Virtuoso and the DBpedia AMI, provides and maintains the public DBpdia endpoint, and employs me.)

Related

Wikipedia Linked Data Fragments endpoint fails

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.

SPARQL BABELNET Prefix not recognised in DBpedia SNORQL

I want to reproduce the example from the Babelnet SPARQL Endpoint in DBpedia/Snorql.
I enter the prefixes and the query as such:
PREFIX bn-lemon: <http://babelnet.org/model/babelnet#>
PREFIX lemon: <http://www.lemon-model.net/lemon#>
SELECT ?entries WHERE {
?entries a lemon:LexicalEntry .
?entries lemon:language ?lang .
FILTER(?lang = "IT")
} LIMIT 30
and I get no result. If I run exactly the same query (without the 2 prefixes) in the Babelnet SPARQL endpoint (https://babelnet.org/sparql/) I get several results. What may be the reason for this? I have hat similar situations when using other prefixes on different subjects outside of DBpedia.
Thank you for the valuable feedback. I have modified my code using SERVICE as such:
PREFIX lemon: <http://lemon-model.net/lemon#>
PREFIX lexinfo: <http://www.lexinfo.net/ontology/2.0/lexinfo#>
SELECT DISTINCT ?entries WHERE {
SERVICE <http://babelnet.org/rdf/> {
?entries a lemon:LexicalEntry .
?entries lemon:language ?lang .
FILTER(?lang = "IT")
}
}
LIMIT 30
However the query is blocked for security reasons: Virtuoso 42000 Error SQ070:SECURITY: Must have select privileges on view DB.DBA.SPARQL_SINV_2 SPARQL query
I assume that people using a public SPARQL accesspoint like DBpedia sparl have no chance. Are there any alternatives beside installing your own accesspoint?

Fuseki Sparql service not able to refer to external rdf resources

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.

"Timeout/query hangs" while executing SPARQL query to DBpedia from Jena

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.

DBpedia SPARQL and predicate connection

I've got a problem with the DBpedia SPARQL endpoint because the properties of the properties like the label of rdf:type are not stocked in the endpoint. So when I run this query:
SELECT *
WHERE{
<http://dbpedia.org/ontology/Place> ?predicat ?object .
OPTIONAL{?predicat rdfs:label ?label}
}
I've got nothing for ?label.
If someone got any idea to solve this problem it would be very helpful.
You can't get the real labels from DBpedia because the SPARQL endpoint doesn't have them. But you can take the local name of the property URI. So, for rdfs:subClassOf you'd get "subClassOf". That's better than nothing. This can be done using Virtuoso's (non-standard) bif:regexp_replace function.
SELECT DISTINCT (bif:regexp_replace(STR(?p), "^.*[/#]", "") AS ?label) WHERE {
<http://dbpedia.org/ontology/Place> ?p ?o .
}
I don't think there's a SPARQL solution. Dbpedia doesn't have the data you want, and I couldn't easily find a SPARQL endpoint for that RDF at W3C. And I don't think the Virtuoso dbpedia endpoint supports federation yet, even if we did find a SPARQL endpoint for W3C.
Happy to be proven wrong on any of those points.