2
votes

I'm calling on http://fr.dbpedia.org/sparql the following SPARQL query:

prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select distinct ?lcs  where {

   {
     ?lcs ^(rdf:type/rdfs:subClassOf*)   <http://fr.dbpedia.org/resource/Honoré_Daumier> , 
                                         <http://fr.dbpedia.org/resource/Auguste_Rodin>;
        a owl:Class .
        filter not exists {
           ?llcs ^(rdf:type/rdfs:subClassOf*)  <http://fr.dbpedia.org/resource/Honoré_Daumier> , 
                                               <http://fr.dbpedia.org/resource/Auguste_Rodin>;
           a owl:Class ;
           rdfs:subClassOf+ ?lcs .
        }
   }
 }

On some call I've http://dbpedia.org/ontology/Person as result, on others call I'm getting http://dbpedia.org/ontology/Person and http://dbpedia.org/ontology/Agent and with others the previous answers plus http://www.w3.org/2002/07/owl#Thing

without nothing to know that a response isn't complete. How can I use the result, if it is a little randomized

1
This article may provide the clues you need. Please also note that it's important to distinguish between the language-based chapter servers like fr.dbpedia.org, and the primary (English) DBpedia.org, not least because the former is currently running Virtuoso Open Source Edition 07.20.3214 built Jul 17 2015, vs the latter which is currently running Enterprise Edition 07.20.3230 built Dec 18 2018. Differences between versions can be significant (though probably not in this specific case)!TallTed
@TallTed To be honest, I never understood why the people do not update. It doesn't take that much time. The same holds for Italian DBpedia (you know this, there have been some questions here asking why some features of SPARQL do not work although they do in recent versions)UninformedUser
Ok, I found another issue with the French DBpedia. The schema is loaded into the graph http://dbpedia.org and the instance data is in http://fr.dbpedia.org - unfortunately, the default graph is not configured to be the union of both...weird. The working query needs to define the union graph explicitely and it works: select distinct ?lcs from <http://fr.dbpedia.org> from <http://dbpedia.org> where ...UninformedUser
@AKSW Thank's, it seems to work, but I need clarification. You obtain the result for the fusion of <dbpedia.org> and <fr.dbpedia.org> which could be different from just <dbpedia.org>. Is the graph <dbpedia.org> only the ontology or the full dbpedia? (and it doesn't explain why a given query gives different results from call to call)user10867087
I'm sorry; I misunderstood part of your question on first read. You're right that the article I linked does not address this. I believe that @AKSW has correctly diagnosed the "split graph" issue as part of the cause (though there are more nuances than he describes). I believe that some of the numerous patches to Virtuoso over the past 4 years will resolve the other things you're hitting (and I've pinged the fr.dbpedia.org admins to encourage them to apply such an update).TallTed

1 Answers

1
votes

The main reason for your query not working as expected is that the data the data is i) split into separate graphs and ii) not all graphs were added to the default graph.

To keep it short, the instance data is contained inside the graph http://fr.dbpedia.org whereas the schema triples will be accessible via http://dbpedia.org graph only. Sometimes, if no graph is given, then the union of some graphs is used as the default graph which will be the dataset at query time. Unfortunately, this doesn't hold for the French DBpedia endpoint, only the instance data graph will be used.

You can check this with

DESCRIBE <http://dbpedia.org/ontology/Person>

which is empty when using either no graph explicitly or the graph http://fr.dbpedia.org, but non-empty for graph http://dbpedia.org.

The way to define the default graph is using the keyword FROM. For your query, it should therefore be

prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select distinct ?lcs  
from <http://fr.dbpedia.org> 
from <http://dbpedia.org> 
where {
     ?lcs ^(rdf:type/rdfs:subClassOf*)   <http://fr.dbpedia.org/resource/Honoré_Daumier> , 
                                         <http://fr.dbpedia.org/resource/Auguste_Rodin>;
        a owl:Class .
        filter not exists {
           ?llcs ^(rdf:type/rdfs:subClassOf*)  <http://fr.dbpedia.org/resource/Honoré_Daumier> , 
                                               <http://fr.dbpedia.org/resource/Auguste_Rodin>;
           a owl:Class ;
           rdfs:subClassOf+ ?lcs .
        }

 }

Note, while this seems to return the correct result, you should also consider the comment from @TallTed regarding possible differences among language chapters (e.g. English vs French Wikipedia as source), release dumps (2016 vs 2018 or even the DBpedia Live) as well as Virtuoso versions used as backend.