Wednesday, April 14, 2004

Moved off the Jena API and onto the Jena Ontology API. Implemented a few tests,which helped me to conceptualize was is going on with ontologies.

The camera ontology is a part of the Jena tutorial, so I've been working with this. It turned out that AN's test was based on this ontology and the code shown in the tutorial, so I was also able to start looking at the problems in our own code.

The test we're running is to ask for all classes which are Cameras. According to the tutorial, this should be equal to "Camera, LargeFormat, Digital". However, this is not what the Jena code returns (it only reutrns LargeFormat and Digital), so I've had to consider the ontology structure carefully.

The Camera query is supposed to return Camera because all classes are defined to be subclasses of themselves. This is apparently a failing in the Ontology layer's inferencing. It's a problem, but for the moment it's not *my* problem. Unfortunately, our code also returns two other nodes, "SLR" and "node96".

Now I understand the SLR, because even the tutorial states that SLR is a subclass of camera. However, it's *not* defined that way in the ontology. Instead, it's defined as an intersection of Camera and a restriction (the restriction is ViewFinder=ThroughThe Lens). IntersectionOf is defined to define a new class, so I'd expect SLR to be a subclass of Camera, but apparently not. This ignores the fact that Figure 3 in the tutorial clearly shows that it is. However, the reference implementation does not return SLR, so I guess I have to live with that.

The node96 is more interesting. This is an anonymous node, and should not show up at all. In fact, it's the anonymous node that defines the restriction for SLRs. That might explain why it gets picked up by the ontology inferencing (in the same way that SLR gets picked up), but it doesn't explain why an anonymous shows up at all. Still I'm learning more as I go.

I tried configuring logging in the AbstractDatabaseSession.query() method to show up so I could see what the Ontolgy inferencing was trying to do. This was MUCH harder than anticipated, but I got it going in the end. It involved putting a logging configuration object into my test class, and lots of fiddling with the log4j configuration file. SR suggested that I wanted to define my logging config file on the command line with a URL, but it turned out that this was not the case. After all this I still didn't see the queries showing up in my output. Finally I resorted to throwing exceptions and calling System.exit() in an effort to see the query getting called, and it never happened. That's when I realised that the Ontology API does not use any kind of query on the database.

Decided that I need to change tack, and try looking at the nodes being traversed by Jena to see why anonymous nodes are showing up when they shouldn't be.

No comments: