1 2 Previous Next 24 Replies Latest reply: Oct 29, 2014 1:49 PM by joguerra RSS

    Oracle semantic tech inference + Protege plugin

    joguerra

      Hi

      From the Protege Plugin, I've installed a simple Ontology for testing on Oracle 11g, I've added a few individuals to the database with no problem at all, though I can't see the inference on the database!!.

      Jena Adapter for Oracle Database I am using these instructions to install Joseki and a Java client. Everything seems okay, I can query the RDF database and the individuals using Joseki and a Jena client.

       

      This snippet is part of the client to perform the inference.

       

      Oracle oracle = new Oracle("jdbc:oracle:thin:@161.x.y.z:1521:NTCSHIST", "user", "password");

              Attachment attachment = Attachment.createInstance(new String[] {}, "OWLPRIME",

                          InferenceMaintenanceMode.NO_UPDATE, QueryOptions.DEFAULT);

                

              final GraphOracleSem graph = new GraphOracleSem(oracle, "M_NAMED_GRAPHS", attachment);

            

              System.out.println("Analyzing db...");

              graph.analyze();

              System.out.println("Infering db...");

              graph.performInference();


      After running this code the database it seems inferred, but when I query it, it looks to me the data wasn't inferred.

      Does anyone have any clue to see how to infer data on Oracle?. Maybe I doing something wrong or I misunderstood something because I got empty response when I query for data that it should be inferred. The ontology should be okay, because when i create individuals on Protege and run the reasoner, the inferred data shows up perfectly.



      Cheers

        • 1. Re: Oracle semantic tech inference + Protege plugin
          alwu-Oracle

          Hi Joguerra,

           

          The snippet looks fine. How did you run the query?

           

          Thanks,

           

          Zhe Wu

          • 2. Re: Oracle semantic tech inference + Protege plugin
            joguerra

            Hi,

             

            I am sorry, but I don't understand your question. I run the client on a remote machine against an ontology deployed on Oracle. You may have to see the ontology to see better what I mean to say.

             

            Thank you

            • 3. Re: Oracle semantic tech inference + Protege plugin
              alwu-Oracle

              Hi Joguerra,

               

              In your client, how did you run the SPARQL query? Can you cut & paste the relevant code snippet?

               

              As an example, the following shows how to run a SPARQL query against a graph with the

              corresponding inference (Example 7-19 in RDF Semantic Graph Support for Apache Jena).

               

              Attachment attachment = Attachment.createInstance(

                new String[] {}, "OWLPRIME",

                InferenceMaintenanceMode.NO_UPDATE, QueryOptions.DEFAULT);

               

              GraphOracleSem graph = new GraphOracleSem(oracle, szModelName, attachment);

                graph.analyze();

                graph.performInference();

               

              query = QueryFactory.create(queryString) ;

                qexec = QueryExecutionFactory.create(query,new ModelOracleSem(graph)) ;

               

              Thanks,


              Zhe

              • 4. Re: Oracle semantic tech inference + Protege plugin
                joguerra

                Hi,

                 

                I am sorry about the delay...

                The snipped below is what I am doing for it. The execution is ok, but I can't get the inference on subclasses or superclasses.

                 

                I have an ontology with one superclass (A) several subclasses (B, C, D). Each of the subclasses is defined by a specific data property type.

                 

                                  A

                    /              ¦               \

                B(p=a)     C(p=b)     D(p=c)

                 

                When I create an individual A with a data property p=a, the database should infer that the individual A belongs to a subclass B and thus it has the B type.

                This works fine on Protege using any of the reasoners, but I can't get this working using the database.

                 

                I am not fully sure whether you can grasp the idea behind of it. Please don't hesitate to contact me !

                 

                Thank you.

                 

                public void oracleInfer() throws SQLException {

                       

                        final Oracle oracle = new Oracle("jdbc:oracle:thin:@X.Y.Z.Q:1521:NTCSHIST", "fuser", "password");

                        Attachment attachment = Attachment.createInstance(new String[] {}, "OWLPRIME",

                                    InferenceMaintenanceMode.NO_UPDATE, QueryOptions.DEFAULT);

                           

                        final GraphOracleSem graph = new GraphOracleSem(oracle, "M_NAMED_GRAPHS", attachment);

                       

                        System.out.println("Analyzing db...");

                        graph.analyze();

                        System.out.println("Infering db...");

                        graph.performInference();

                       

                        graph.close();

                }

                • 5. Re: Oracle semantic tech inference + Protege plugin
                  alwu-Oracle

                  Can you please cut & paste here the class definitions?

                   

                  Thanks,

                   

                  Zhe Wu

                  • 6. Re: Re: Oracle semantic tech inference + Protege plugin
                    joguerra
                    <?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 geosparql "http://www.opengis.net/ont/geosparql#" >
                        <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
                        <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
                        <!ENTITY starguidecatalog "http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#" >
                    ]>
                    
                    
                    <rdf:RDF xmlns="http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#"
                        xml:base="http://www.tng.iac.es/ontologies/2014/6/starguidecatalog"
                        xmlns:geosparql="http://www.opengis.net/ont/geosparql#"
                        xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
                        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:starguidecatalog="http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#">
                        <owl:Ontology rdf:about="http://www.tng.iac.es/ontologies/2014/6/starguidecatalog">
                            <owl:imports rdf:resource="http://www.opengis.net/ont/geosparql"/>
                            <owl:imports rdf:resource="http://www.opengis.net/ont/sf"/>
                        </owl:Ontology>
                       
                    
                    
                        <!--
                        ///////////////////////////////////////////////////////////////////////////////////////
                        //
                        // Object Properties
                        //
                        ///////////////////////////////////////////////////////////////////////////////////////
                        -->
                    
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#border -->
                    
                        <owl:ObjectProperty rdf:about="&starguidecatalog;border">
                            <rdf:type rdf:resource="&owl;SymmetricProperty"/>
                            <rdfs:domain rdf:resource="&starguidecatalog;Tile"/>
                            <rdfs:range rdf:resource="&starguidecatalog;Tile"/>
                            <owl:inverseOf rdf:resource="&starguidecatalog;border"/>
                        </owl:ObjectProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#hasPointGeometry -->
                    
                        <owl:ObjectProperty rdf:about="&starguidecatalog;hasPointGeometry">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:subPropertyOf rdf:resource="&geosparql;hasGeometry"/>
                            <rdfs:range rdf:resource="http://www.opengis.net/ont/sf#Point"/>
                            <rdfs:domain rdf:resource="&starguidecatalog;AstronomicalObject"/>
                        </owl:ObjectProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#insideOf -->
                    
                        <owl:ObjectProperty rdf:about="&starguidecatalog;insideOf">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:domain rdf:resource="&starguidecatalog;AstronomicalObject"/>
                            <rdfs:range rdf:resource="&starguidecatalog;Tile"/>
                        </owl:ObjectProperty>
                       
                    
                    
                        <!--
                        ///////////////////////////////////////////////////////////////////////////////////////
                        //
                        // Data properties
                        //
                        ///////////////////////////////////////////////////////////////////////////////////////
                        -->
                    
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#astroClass -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;astroClass">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:domain rdf:resource="&starguidecatalog;AstronomicalObject"/>
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;targetInfo"/>
                            <rdfs:range rdf:resource="&xsd;float"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#coordinates -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;coordinates">
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;targetInfo"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#dec -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;dec">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:domain rdf:resource="&starguidecatalog;AstronomicalObject"/>
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;coordinates"/>
                            <rdfs:range rdf:resource="&xsd;float"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#epoch -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;epoch">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:domain rdf:resource="&starguidecatalog;AstronomicalObject"/>
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;targetInfo"/>
                            <rdfs:range rdf:resource="&xsd;integer"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#f -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;f">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;magnitude"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#id -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;id">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:domain rdf:resource="&starguidecatalog;AstronomicalObject"/>
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;targetInfo"/>
                            <rdfs:range rdf:resource="&xsd;integer"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#j -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;j">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;magnitude"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#magnitude -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;magnitude">
                            <rdfs:domain rdf:resource="&starguidecatalog;AstronomicalObject"/>
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;targetInfo"/>
                            <rdfs:range rdf:resource="&xsd;float"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#n -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;n">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;magnitude"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#ra -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;ra">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:domain rdf:resource="&starguidecatalog;AstronomicalObject"/>
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;coordinates"/>
                            <rdfs:range rdf:resource="&xsd;float"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#targetInfo -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;targetInfo">
                            <owl:propertyDisjointWith rdf:resource="&starguidecatalog;tileInfo"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#tileInfo -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;tileInfo">
                            <rdfs:domain rdf:resource="&starguidecatalog;Tile"/>
                            <rdfs:range rdf:resource="&xsd;float"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#v -->
                    
                        <owl:DatatypeProperty rdf:about="&starguidecatalog;v">
                            <rdf:type rdf:resource="&owl;FunctionalProperty"/>
                            <rdfs:subPropertyOf rdf:resource="&starguidecatalog;magnitude"/>
                        </owl:DatatypeProperty>
                       
                    
                    
                        <!--
                        ///////////////////////////////////////////////////////////////////////////////////////
                        //
                        // Classes
                        //
                        ///////////////////////////////////////////////////////////////////////////////////////
                        -->
                    
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#AstronomicalCoordinate -->
                    
                        <owl:Class rdf:about="&starguidecatalog;AstronomicalCoordinate">
                            <rdfs:subClassOf rdf:resource="http://www.opengis.net/ont/sf#Point"/>
                            <rdfs:subClassOf rdf:resource="&starguidecatalog;Sky"/>
                            <rdfs:subClassOf>
                                <owl:Restriction>
                                    <owl:onProperty rdf:resource="&starguidecatalog;hasPointGeometry"/>
                                    <owl:allValuesFrom rdf:resource="http://www.opengis.net/ont/sf#Point"/>
                                </owl:Restriction>
                            </rdfs:subClassOf>
                        </owl:Class>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#AstronomicalObject -->
                    
                        <owl:Class rdf:about="&starguidecatalog;AstronomicalObject">
                            <owl:equivalentClass>
                                <owl:Class>
                                    <owl:unionOf rdf:parseType="Collection">
                                        <rdf:Description rdf:about="&starguidecatalog;Galaxy"/>
                                        <rdf:Description rdf:about="&starguidecatalog;Star"/>
                                        <rdf:Description rdf:about="&starguidecatalog;Supernova"/>
                                    </owl:unionOf>
                                </owl:Class>
                            </owl:equivalentClass>
                            <rdfs:subClassOf rdf:resource="&starguidecatalog;Sky"/>
                            <rdfs:subClassOf>
                                <owl:Restriction>
                                    <owl:onProperty rdf:resource="&starguidecatalog;hasPointGeometry"/>
                                    <owl:allValuesFrom rdf:resource="http://www.opengis.net/ont/sf#Point"/>
                                </owl:Restriction>
                            </rdfs:subClassOf>
                        </owl:Class>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Galaxy -->
                    
                        <owl:Class rdf:about="&starguidecatalog;Galaxy">
                            <owl:equivalentClass>
                                <owl:Class>
                                    <owl:intersectionOf rdf:parseType="Collection">
                                        <rdf:Description rdf:about="&starguidecatalog;AstronomicalObject"/>
                                        <owl:Restriction>
                                            <owl:onProperty rdf:resource="&starguidecatalog;astroClass"/>
                                            <owl:hasValue rdf:datatype="&xsd;float">3.0</owl:hasValue>
                                        </owl:Restriction>
                                    </owl:intersectionOf>
                                </owl:Class>
                            </owl:equivalentClass>
                            <rdfs:subClassOf rdf:resource="&starguidecatalog;AstronomicalObject"/>
                            <rdfs:subClassOf>
                                <owl:Restriction>
                                    <owl:onProperty rdf:resource="&starguidecatalog;border"/>
                                    <owl:allValuesFrom rdf:resource="&starguidecatalog;Tile"/>
                                </owl:Restriction>
                            </rdfs:subClassOf>
                            <owl:disjointWith rdf:resource="&starguidecatalog;Star"/>
                            <owl:disjointWith rdf:resource="&starguidecatalog;Supernova"/>
                        </owl:Class>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Sky -->
                    
                        <owl:Class rdf:about="&starguidecatalog;Sky"/>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Star -->
                    
                        <owl:Class rdf:about="&starguidecatalog;Star">
                            <owl:equivalentClass>
                                <owl:Class>
                                    <owl:intersectionOf rdf:parseType="Collection">
                                        <rdf:Description rdf:about="&starguidecatalog;AstronomicalObject"/>
                                        <owl:Restriction>
                                            <owl:onProperty rdf:resource="&starguidecatalog;astroClass"/>
                                            <owl:hasValue rdf:datatype="&xsd;float">2.0</owl:hasValue>
                                        </owl:Restriction>
                                    </owl:intersectionOf>
                                </owl:Class>
                            </owl:equivalentClass>
                            <rdfs:subClassOf rdf:resource="&starguidecatalog;AstronomicalObject"/>
                            <rdfs:subClassOf>
                                <owl:Restriction>
                                    <owl:onProperty rdf:resource="&starguidecatalog;border"/>
                                    <owl:allValuesFrom rdf:resource="&starguidecatalog;Tile"/>
                                </owl:Restriction>
                            </rdfs:subClassOf>
                            <owl:disjointWith rdf:resource="&starguidecatalog;Supernova"/>
                        </owl:Class>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Supernova -->
                    
                        <owl:Class rdf:about="&starguidecatalog;Supernova">
                            <owl:equivalentClass>
                                <owl:Class>
                                    <owl:intersectionOf rdf:parseType="Collection">
                                        <rdf:Description rdf:about="&starguidecatalog;AstronomicalObject"/>
                                        <owl:Restriction>
                                            <owl:onProperty rdf:resource="&starguidecatalog;astroClass"/>
                                            <owl:hasValue rdf:datatype="&xsd;float">1.0</owl:hasValue>
                                        </owl:Restriction>
                                    </owl:intersectionOf>
                                </owl:Class>
                            </owl:equivalentClass>
                            <rdfs:subClassOf rdf:resource="&starguidecatalog;AstronomicalObject"/>
                            <rdfs:subClassOf>
                                <owl:Restriction>
                                    <owl:onProperty rdf:resource="&starguidecatalog;border"/>
                                    <owl:allValuesFrom rdf:resource="&starguidecatalog;Tile"/>
                                </owl:Restriction>
                            </rdfs:subClassOf>
                        </owl:Class>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Tile -->
                    
                        <owl:Class rdf:about="&starguidecatalog;Tile">
                            <rdfs:subClassOf rdf:resource="http://www.opengis.net/ont/sf#Polygon"/>
                            <rdfs:subClassOf rdf:resource="&starguidecatalog;Sky"/>
                        </owl:Class>
                       
                    
                    
                        <!--
                        ///////////////////////////////////////////////////////////////////////////////////////
                        //
                        // Individuals
                        //
                        ///////////////////////////////////////////////////////////////////////////////////////
                        -->
                    
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Sun -->
                    
                        <owl:NamedIndividual rdf:about="&starguidecatalog;Sun">
                            <rdf:type rdf:resource="&starguidecatalog;Star"/>
                            <dec rdf:datatype="&xsd;float">0.773</dec>
                            <ra rdf:datatype="&xsd;float">1.0</ra>
                            <astroClass rdf:datatype="&xsd;float">2.0</astroClass>
                            <hasPointGeometry rdf:resource="&starguidecatalog;SunCoordinates"/>
                        </owl:NamedIndividual>
                       
                    
                    
                        <!-- http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#SunCoordinates -->
                    
                        <owl:NamedIndividual rdf:about="&starguidecatalog;SunCoordinates">
                            <rdf:type rdf:resource="&starguidecatalog;AstronomicalCoordinate"/>
                            <geosparql:asWKT rdf:datatype="&geosparql;wktLiteral">Point(12.0 13.3)</geosparql:asWKT>
                        </owl:NamedIndividual>
                    </rdf:RDF>
                    
                    
                    
                    <!-- Generated by the OWL API (version 3.4.2) http://owlapi.sourceforge.net -->
                    
                    

                     

                     

                    Please note this is a scenario for testing proposes only. It's not meant to be a real scenario !

                     

                    Cheers

                    • 7. Re: Oracle semantic tech inference + Protege plugin
                      alwu-Oracle

                      Hi,

                       

                      I have loaded it up and executed the inference API. I got a bunch of inferred relationships.

                      Can you please compile and run the following code?

                       

                      public class Test266505

                      {

                        public static void main(String[] args) throws Exception

                        {

                          String szJdbcURL = args[0];

                          String szUser    = args[1];

                          String szPasswd  = args[2];

                       

                          String szModelName = args[3];

                         

                          Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);

                         

                          Model model = ModelOracleSem.createOracleSemModel(oracle, szModelName);

                             

                          // load the ontology

                          InputStream in = FileManager.get().open(args[4]);

                          model.read(in, null); // incremental is fine since data is small

                        

                          Attachment attachment = Attachment.createInstance(

                              new String[] {}, "OWLPRIME",

                              InferenceMaintenanceMode.NO_UPDATE,

                              QueryOptions.DEFAULT);

                       

                          GraphOracleSem graph = new GraphOracleSem(oracle, szModelName, attachment);

                          graph.analyze();

                          graph.performInference();

                       

                       

                          Query query = QueryFactory.create(

                           "PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#INF_ONLY=T>select ?s ?p ?o where {?s ?p ?o}"

                          );

                          QueryExecution qexec = QueryExecutionFactory.create(query,new ModelOracleSem(graph)) ;

                       

                          try {

                            int iTriplesCount = 0;

                            ResultSet results = qexec.execSelect() ;

                            for ( ; results.hasNext() ; ) {

                              QuerySolution soln = results.nextSolution() ;

                              System.out.println("soln : " + soln.toString());

                              iTriplesCount++;

                            }

                            System.out.println("Infered triples count: " + iTriplesCount);

                          }

                          finally {

                            qexec.close() ;

                          }

                       

                          model.close();   

                          oracle.dispose();

                        }

                      }

                       

                      In my test, the original model has 151 triples and inferred graph has 130+ new relationships.

                       

                      Thanks,


                      Zhe Wu

                      • 8. Re: Oracle semantic tech inference + Protege plugin
                        joguerra

                        hi

                        Shoud I delete first the ontology before running this code?

                        • 9. Re: Oracle semantic tech inference + Protege plugin
                          joguerra

                          Never mind I ran it with another model name!

                          I ran  your code and now the question is, if I run this query:

                           

                          SELECT ?name

                          WHERE

                            { ?name rdf:type astro:Star .}

                           

                          I got the "Sun" which is correct, though running this other query instead:

                           

                          SELECT ?name

                          WHERE

                            { ?name rdf:type astro:AstronomicalObject .}

                           

                          it comes back with an empty result set! when "AstronomicalObject" is a superclass of "Star". Why didn't infer that?

                           

                          Thank you

                          • 10. Re: Oracle semantic tech inference + Protege plugin
                            alwu-Oracle

                            Hi,

                             

                            Did you run it with the Attachment?

                             

                            Here is a quick test I did. First of all, you are right that "AstronomicalObject" is a superclass of "Star".

                            I am using SEM_MATCH to run the SPARQL.

                             

                            SQL>  select sc

                            from table(sem_match('{?sc rdfs:subClassOf <http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#AstronomicalObject> }', sem_models('test266505'),sem_rulebases('owlprime'),null,null,null));

                            ==>

                            http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Star

                            http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Galaxy

                            http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Supernova

                            ...

                             

                            And Sun is indeed an AstronomicalObject

                             

                            SQL> select i

                            from table(sem_match('{?i rdf:type  <http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#AstronomicalObject> }',

                            sem_models('test266505'),sem_rulebases('owlprime'),null,null,null));

                            ==>

                            http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Sun

                             

                            Hope it helps,


                            Zhe Wu

                            • 11. Re: Oracle semantic tech inference + Protege plugin
                              alwu-Oracle

                              BTW, replacing the {?s ?p ?o} query in the above Java code snippet will give you the same answer from Jena Adapter.

                               

                              Query query = QueryFactory.create(
                              "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#>select ?s where {?s rdf:type <http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#AstronomicalObject>}"

                              ...

                               

                              soln : ( ?s = <http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#Sun> )

                               

                               

                              Thanks,


                              Zhe Wu

                              • 12. Re: Re: Oracle semantic tech inference + Protege plugin
                                joguerra

                                Hi,

                                I can't get the right output using Joseki or Jena interface. If I run the query using sqlplus as you pointed out before

                                and it works!!. So the inference works, though running the query below using either joseki or Jena API, it doesn't.

                                 

                                Java Jena API.

                                final Query query = QueryFactory.create("PREFIX astro: <http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#> " +
                                        "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
                                        "PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#dop=4,timeout=1> " +
                                        " select ?name WHERE {?name rdf:type astro:AstronomicalObject .}");
                                

                                 

                                 

                                Joseki interface

                                 

                                PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
                                PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
                                PREFIX xsd:  <http://www.w3.org/2001/XMLSchema#>
                                PREFIX owl:  <http://www.w3.org/2002/07/owl#>
                                
                                PREFIX astro: <http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#>
                                
                                PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#dop=4,timeout=1>
                                
                                SELECT ?name where {?name rdf:type astro:AstronomicalObject .}
                                
                                

                                 

                                 

                                Can you please give me a clue about what is going on?.

                                 

                                Thank you for your replies.

                                • 13. Re: Oracle semantic tech inference + Protege plugin
                                  alwu-Oracle

                                  Hi,

                                   

                                  That is good news. We are making progress.

                                   

                                  How did you run the query using Jena APIs? Can you please try the following?

                                  ...

                                      Attachment attachment = Attachment.createInstance(

                                          new String[] {}, "OWLPRIME",

                                          InferenceMaintenanceMode.NO_UPDATE,

                                          QueryOptions.DEFAULT);

                                       GraphOracleSem graph = new GraphOracleSem(oracle, szModelName, attachment);

                                       Query query = QueryFactory.create(

                                       "... your sparql here ..."

                                      );

                                      QueryExecution qexec = QueryExecutionFactory.create(query,new ModelOracleSem(graph)) ;

                                   

                                      ResultSet results = qexec.execSelect() ;

                                   

                                  Once we get the correct results using Jena APIs, it is quite straightforward to configure Joseki.

                                   

                                  Thanks,

                                   

                                  Zhe Wu

                                  • 14. Re: Re: Oracle semantic tech inference + Protege plugin
                                    joguerra

                                    Indeed   and thank you in advance for your help!

                                     

                                    Anyway, I ran the code below, I have no luck though.

                                     

                                    public void fetchGSC() throws SQLException {
                                         
                                            final Oracle oracle = new Oracle("jdbc:oracle:thin:@A.B.C.D:1521:NTCSHIST", "user", "password");
                                            final ModelOracleSem modelDest = ModelOracleSem.createOracleSemModel(oracle, "GS_CATALOG");
                                         
                                            Attachment attachment = Attachment.createInstance(new String[] {}, "OWLPRIME",
                                                        InferenceMaintenanceMode.NO_UPDATE, QueryOptions.DEFAULT);
                                    //        attachment.setUseLocalInference(true);
                                    //        attachment.setDefGraphForLocalInference("GS_CATALOG");
                                    //        attachment.setInferenceOption("DOP=4,RAW8=T");
                                         
                                            final GraphOracleSem graph = new GraphOracleSem(oracle, "GS_CATALOG", attachment);
                                         
                                            DatasetGraphOracleSem dsgos = DatasetGraphOracleSem.createFrom(graph);
                                            graph.close();
                                         
                                            System.out.println("Infered size: " + dsgos.getInferredGraphSize());
                                         
                                            final Query query = QueryFactory.create("PREFIX astro: <http://www.tng.iac.es/ontologies/2014/6/starguidecatalog#> " +
                                            "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
                                            "PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#dop=4,timeout=1> " +
                                            " select ?name WHERE {?name rdf:type astro:AstronomicalObject .}");
                                         
                                            QueryExecution qexec = QueryExecutionFactory.create(query, modelDest);
                                         
                                            ResultSet results = qexec.execSelect();
                                            ResultSetFormatter.out(System.out, results, query);
                                         
                                            dsgos.close();
                                            oracle.dispose();
                                        }
                                    
                                    

                                     

                                    The query returns a empty value.

                                     

                                    If I swap the line 24 by this one:

                                    QueryExecution qexec = QueryExecutionFactory.create(query, new ModelOracleSem(graph));
                                    
                                    

                                     

                                    I got a NPE.

                                     

                                    Exception in thread "main" java.lang.NullPointerException
                                        at com.hp.hpl.jena.rdf.model.impl.ModelCom.withDefaultMappings(ModelCom.java:806)
                                        at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:54)
                                        at com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:50)
                                        at oracle.spatial.rdf.client.jena.ModelOracleSem.<init>(ModelOracleSem.java:71)
                                        at tng.core.client2.Client4Oracle.getInference(Client4Oracle.java:196)
                                        at tng.core.client2.Client4Oracle.main(Client4Oracle.java:74)
                                    
                                    
                                    1 2 Previous Next