1 Reply Latest reply: May 23, 2011 11:31 AM by alwu-Oracle RSS

    Missing Simple Answer

    863703
      Hello,

      I am doing some testing over oracle's ST and have ran into a strange case, which I don't know whether I am doing something wrong or it is a bug.

      I have a simple owl ontology with two axioms:

      SubClassOf( A intersectionOf(B C))
      ClassAssertion(A a)

      and query for instances of B. Obviously a is an instance of B but I don't get this back as an answer. If I remove the C conjunct (i.e., have the axiom SubClassOf(A B)), then I get that a is an instance of B. If I am not doing something wrong this kind of implies that such axioms are not "normalised" into SubClassOf(A B) and SubClassOf(A C) (?)


      I am using Oracle 11g and accessing ST through Jena 2.6.3 and with the Jena adaptor (jena_adaptor_for_release11.2.0.2).


      Here is the Java class I am running


      ========= JAVA ==============


      package com.clarkparsia.pelletdb.examples;

      import static com.clarkparsia.pelletdb.examples.ExampleConnectionParams.JDBC_URL;
      import static com.clarkparsia.pelletdb.examples.ExampleConnectionParams.MODEL_NAME;
      import static com.clarkparsia.pelletdb.examples.ExampleConnectionParams.PASSWORD;
      import static com.clarkparsia.pelletdb.examples.ExampleConnectionParams.USERNAME;

      import java.io.File;
      import java.sql.SQLException;

      import oracle.spatial.rdf.client.jena.Attachment;
      import oracle.spatial.rdf.client.jena.GraphOracleSem;
      import oracle.spatial.rdf.client.jena.InferenceMaintenanceMode;
      import oracle.spatial.rdf.client.jena.ModelOracleSem;
      import oracle.spatial.rdf.client.jena.Oracle;
      import oracle.spatial.rdf.client.jena.QueryOptions;

      import com.hp.hpl.jena.query.Query;
      import com.hp.hpl.jena.query.QueryExecution;
      import com.hp.hpl.jena.query.QueryExecutionFactory;
      import com.hp.hpl.jena.query.QueryFactory;
      import com.hp.hpl.jena.query.QuerySolution;
      import com.hp.hpl.jena.query.ResultSet;
      import com.hp.hpl.jena.rdf.model.InfModel;

      public class Bug {
           
           public static void main(String[] args) throws Exception {
                Oracle oracle;
                ModelOracleSem dbModel;
                QueryExecution queryExecution;
                Query loadedQuery;
                
                String ontology = "C:/OWLPrimeBug.owl";
                String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
                                    "SELECT DISTINCT ?X WHERE {" +
                                    "?X rdf:type <http://www.semanticweb.org/ontologies/2011/4/Ontology1305861504984.owl#B> .}";
                loadedQuery = QueryFactory.create( query );
                
                oracle = new Oracle( JDBC_URL, USERNAME, PASSWORD );
                dbModel = ModelOracleSem.createOracleSemModel( oracle, MODEL_NAME );

                dbModel.read( "file:/" + ontology );

      //          Attachment attachment = Attachment.createInstance( new String[] {}, "RDFS", InferenceMaintenanceMode.NO_UPDATE, QueryOptions.DEFAULT);
                Attachment attachment = Attachment.createInstance( new String[] {}, "OWLPRIME", InferenceMaintenanceMode.NO_UPDATE, QueryOptions.DEFAULT);
                GraphOracleSem graph = new GraphOracleSem(oracle, MODEL_NAME, attachment);
                graph.performInference();
                dbModel = new ModelOracleSem( graph );
      //          dbModel.commit();

                
      //          queryExecution = QueryExecutionFactory.create( loadedQuery, pelletDbModel );
           queryExecution = QueryExecutionFactory.create( loadedQuery, dbModel );
           
                ResultSet rs = queryExecution.execSelect();
                if( rs == null )
                     System.out.println( "h: " + 0 );

                long results = 0;
      //          ResultSetFormatter.out( rs );
                
                while( rs.hasNext() ){
                     QuerySolution sol = rs.next();
      //               System.out.println( sol.get("X") );
                     results++;
                }
                System.out.println( results );
                
                dbModel.removeAll();
                dbModel.commit();
                dbModel.close();
                oracle.dispose();
           }

      }




      =============== ONTOLOGY ===============



      <?xml version="1.0"?>


      <!DOCTYPE rdf:RDF [
      <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
      <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
      <!ENTITY owl2xml "http://www.w3.org/2006/12/owl2-xml#" >
      <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
      <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
      <!ENTITY Ontology1305861504984 "http://www.semanticweb.org/ontologies/2011/4/Ontology1305861504984.owl#" >
      ]>


      <rdf:RDF xmlns="http://www.semanticweb.org/ontologies/2011/4/Ontology1305861504984.owl#"
      xml:base="http://www.semanticweb.org/ontologies/2011/4/Ontology1305861504984.owl"
      xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
      xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#"
      xmlns:owl="http://www.w3.org/2002/07/owl#"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:Ontology1305861504984="http://www.semanticweb.org/ontologies/2011/4/Ontology1305861504984.owl#">
      <owl:Ontology rdf:about=""/>



      <!--
      ///////////////////////////////////////////////////////////////////////////////////////
      //
      // Classes
      //
      ///////////////////////////////////////////////////////////////////////////////////////
      -->




      <!-- http://www.semanticweb.org/ontologies/2011/4/Ontology1305861504984.owl#A -->

      <owl:Class rdf:about="#A">
      <rdfs:subClassOf>
      <owl:Class>
      <owl:intersectionOf rdf:parseType="Collection">
      <rdf:Description rdf:about="#B"/>
      <rdf:Description rdf:about="#C"/>
      </owl:intersectionOf>
      </owl:Class>
      </rdfs:subClassOf>
      </owl:Class>



      <!-- http://www.semanticweb.org/ontologies/2011/4/Ontology1305861504984.owl#B -->

      <owl:Class rdf:about="#B"/>



      <!-- http://www.semanticweb.org/ontologies/2011/4/Ontology1305861504984.owl#C -->

      <owl:Class rdf:about="#C"/>



      <!-- http://www.w3.org/2002/07/owl#Thing -->

      <owl:Class rdf:about="&owl;Thing"/>



      <!--
      ///////////////////////////////////////////////////////////////////////////////////////
      //
      // Individuals
      //
      ///////////////////////////////////////////////////////////////////////////////////////
      -->




      <!-- http://www.semanticweb.org/ontologies/2011/4/Ontology1305861504984.owl#a -->

      <A rdf:about="#a">
      <rdf:type rdf:resource="&owl;Thing"/>
      </A>
      </rdf:RDF>



      <!-- Generated by the OWL API (version 2.2.1.1138) http://owlapi.sourceforge.net -->
        • 1. Re: Missing Simple Answer
          alwu-Oracle
          Hi,

          I assume you are using Oracle Database release 11.2.0.2.

          What you observed is expected. OWLPrime itself does not handle intersection semantics. To get what you want, there are two approaches.

          1) use OWL2RL instead of OWLPRIME, or
          2) use performInference("INTERSECT,INTERSECTSCOH") instead of performInference()

          The 2) specifies two additional ifnerence components (on top of OWLPrime) for intersection related semantics. You need to run deleteInference first.

          Thanks,

          Zhe Wu