On Tue, May 14, 2013 at 10:20 AM, Ed Swing <[email protected]> wrote:
> I discovered a significant bug when dealing with SameAs and functional
> properties. Here’s the Java code:
>
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.util.Iterator;
> import com.hp.hpl.jena.ontology.*;
> import com.hp.hpl.jena.rdf.model.ModelFactory;
> import com.hp.hpl.jena.reasoner.ValidityReport;
>
> public class SameAsTest {
>     public static void main(String[] args) throws IOException {
>         OntModel m =
> ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
>         FileInputStream inStream = new
> FileInputStream("ontology/vehicle.owl");
>         m.read(inStream, null);
>         inStream.close();
>         String uriBase = m.getNsPrefixURI("");
>         OntClass vehCls = m.getOntClass(uriBase + "Vehicle");
>         Individual myCar = vehCls.createIndividual(uriBase + "/data/myCar");
>         DatatypeProperty wheels = m.getDatatypeProperty(uriBase +
> "numWheels");
>         // state that myCar has 4 wheels
>         myCar.addProperty(wheels, "4");
>         // do the same for another vehicle
>         Individual redCrv = vehCls.createIndividual(uriBase +
> "/data/redCrv");
>         redCrv.addProperty(wheels, "4");
>         // now add the fact that the redCrv and myCar are the same object
>         myCar.addSameAs(redCrv);
>         ValidityReport rept = m.validate();
>         for (Iterator<ValidityReport.Report> riter = rept.getReports();
> riter
>             .hasNext();) {
>             ValidityReport.Report rep = riter.next();
>             System.out.println("ValRep: " + rep.getDescription());
>         }
>     }
> }
>
> The relevant ontology is attached to this message. The crucial thing is that
> numWheels is a datatype property, with a max cardinality of 1 for the
> Vehicle class.
>
> When the two vehicles are linked via the SameAs property, the number of
> wheels are also linked because of cardinality. However, sameAs doesn’t allow
> datatype values (literals) to be linked. It’s even more annoying in this
> case since the two values are in fact the same.
>
> This also occurs if I declare the numWheels property as a functional
> property, so that’s no help.

This list doesn't allow attachments, so no one's got your ontology.
I'm not a Jena dev, so I can't necessarily help with the bug, but:
from the initial reading of the email, I'm not clear exactly what the
bug was.  What was the expected behavior?  What is the actual
behavior?  An inconsistency that wasn't detected?  A consistent
ontology reported as inconsistency? ... ?

//JT
-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Reply via email to