4 Replies Latest reply on Mar 27, 2009 4:54 PM by 652134

    Inference through Jena Adaptor vs. Database

    652134
      Oracle 11.1.0.6.0
      Jena 2.5.6
      Oracle Jena Driver Release 2

      Hello,
      I would like to use inference using the OWLSIF rules on one of my models. I can do this through the Jena adaptor using the Attachment object and the performInference() method. However, it takes several minutes to perform the inference each time. I know I can create an entailment using the database sem_apis.create_entailment method. This method appears to materialize new triples according to the inference rule. It also appears to persist them in the database. Is there some way to use the create_entailment in conjunction with Jena? Basically, I'm looking for a way to speed up my queries when using inference. I would prefer to use Jena because we are trying to use SPARQL for all our queries.
      Thanks,
      Chuck
        • 1. Re: Inference through Jena Adaptor vs. Database
          alwu-Oracle
          Hi Chuck,

          Actually, Jena Adaptor's performInference will invoke create_entailment API. How many triples are generated and how big is your ontology? Have you run analyze method in GraphOracleSem?

          Thanks,

          Zhe Wu
          • 2. Re: Inference through Jena Adaptor vs. Database
            652134
            Hi Zhe,

            Here is the info you requested:

            First, I executed the graph.perfromInference() method. Then, I executed the following methods to determine the graph size:

            graph.getSize() - 20970
            graph.getInferredSize - 20680

            The graph contains OWL data. In the past, I have run the Oracle sem_apis.analyze_models() method on the model. No new data has been added since then.

            Here is my code. The rulelist variable equals {"OWLSIF"} and the graphList contains a single model name:

            try {
            Attachment attachment = Attachment.createInstance(
            Attachment.NO_ADDITIONAL_MODELS, rulelist,
            InferenceMaintenanceMode.NO_UPDATE,
            QueryOptions.DEFAULT);

            DataSource ds = DatasetFactory.create();
            graph = new GraphOracleSem(oracle, graphList[0], attachment);
            ModelOracleSem model = new ModelOracleSem(graph);
            ds.setDefaultModel(model);
            graph.performInference();

            query = QueryFactory.create(queryText);
            qexec = QueryExecutionFactory.create(query, ds);

            ResultSet results = qexec.execSelect();

            returnResultSet = parseResultSet(results);

            qexec.close();

            } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
            } finally {
            try {
            if (graph != null) {
            if (graph.getStatusForEntailedGraph() != GraphOracleSem.NO_RULEBASE) {
            graph.deleteInference();
            }
            }
            } catch (Exception ex) {
            System.out.println("Error attempting to delete inference: " + ex.getMessage());

            }
            }
            • 3. Re: Inference through Jena Adaptor vs. Database
              alwu-Oracle
              Hi Chuck,

              Is there a particular reason you want to use OWLSIF instead of OWLPrime?

              Could you add a few timing code around performInference? Basically, I want
              to figure out exactly how much time is spent out inference.

              BTW, you remove inference after one query. Is that necessary? It is a good
              idea to keep the inferred data and use it again and again for queries.

              Thanks,

              Zhe
              • 4. Re: Inference through Jena Adaptor vs. Database
                652134
                Thanks Zhe. I wrote this inference code a few months ago and I haven't looked at it in a while. I was deleting the inference because I thought it was causing problems on subsequent runs. It is not. The inference runs fast now.