gsamaras
gsamaras

Reputation: 73424

Reasoning doesn't give same results with *

I am enabling Forward chaining like this:

static final String inputData = "http://cgi.di.uoa.gr/~pms509/past_projects/2014-2015/hw1/kallikratis.n3";
MemoryStore store = new MemoryStore();
Repository repo = new SailRepository(new ForwardChainingRDFSInferencer(store));
System.out.println("Forward chaining enabled");
repo.initialize();

//Store file
File file = new File(inputData);
String fileBaseURI = "http://www.semanticweb.org/owl/owlapi/turtle";
RDFFormat fileRDFFormat = RDFFormat.N3;

RepositoryConnection con = repo.getConnection();
con.add(file, fileBaseURI, fileRDFFormat);
...

and then I query like this:

"SELECT ?class "                                +
"WHERE {"                                       +
        "?rsrc geo:has_name \"foo\" . "         +
        "?rsrc geo:belongs_to ?a ."             +
"}";

However this will not give me same results as with geo:belongs_to*. I will get only the direct belongs_to linkage, not the inferred ones, as I would expect!

I want to get same results however, why I am not?

Upvotes: 3

Views: 79

Answers (1)

Jeen Broekstra
Jeen Broekstra

Reputation: 22052

The RDFS inferencer only does, well, RDFS inferencing - that is, it reasons using the rules defined in the RDF Semantics. These rules only cover relatively basic things such as subclass/type inheritance, and domain/range inference. So for example, if your data has a class Car and it defines Car as a subclass of Vehicle, then the RDFS inferencer will infer that any instance of the class Car is also an instance of Vehicle.

But this kind of inheritance only works for these specific relations (subclass, type, subpropertyof). It does not automatically infer in the general case, that if X someProperty Y and Y someProperty Z, that it then follows that X someProperty Z.

If you want that kind of reasoning support, you either need a custom rule reasoner (Sesame has some limited support for this, with improved support in the form of SPIN rules coming out soon), or you need to move to the next level of expressivity in ontology languages, which is OWL (in which case, a Sesame-compatible OWL reasoner like Ontotext GraphDB or Stardog is needed). Or alternatively, just solve it at query time (for example by using a transitive property path).

Upvotes: 4

Related Questions