Jena: How to deduce problems with data / results

I would like to use the output capabilities of Jena, but I am having performance issues when I use InfModel.

Here is a simplified overview of my ontology:

Properties:

hasX (Ranges(intersection): X, inverse properties: isXOf) |-- hasSpecialX (Ranges(intersection): X, inverse properties: isSpecialXOf) isXOf (Domains(intersection): X, inverse properties: hasX) |--isSpecialXOf (Domains(intersection): X, inverse properties: hasSpecialX) 

In addition, there is a class 'Object':

 Object hasSpecialX some X 

The following data has been explicitly saved:

 SomeObject a Object SomeX a X SomeObject hasSpecialX SomeX 

Using the following query, I would like to determine which class the instance belongs to. According to the assumptions made, only "SomeObject" should be returned.

 SELECT ?x WHERE { ?x :hasX :SomeX . } 

However, the ds.getDefaultModel() request does not work, because the data is not saved explicitly. When I use infModel , on the other hand, the request never ends. In the longest time, I waited 25 minutes before the interruption. (The tripestor is about 180 MB in size)

This is my code:

 OntModel ont = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null); ont.read("file:..." , "RDF/XML"); Reasoner reasoner = ReasonerRegistry.getOWLMicroReasoner(); reasoner = reasoner.bindSchema(ont); Dataset dataset = TDBFactory.createDataset(...); Model model = dataset.getDefaultModel(); InfModel infModel = ModelFactory.createInfModel(reasoner, model); QueryExecution qe = null; ResultSet rs; try { String qry = "SELECT ?x WHERE { ?x :hasX :SomeX . }"; qe = QueryExecutionFactory.create(qry, infModel); rs = qe.execSelect(); while(rs.hasNext()) { QuerySolution sol = rs.nextSolution(); System.out.println(sol.get("x")); } } finally { qe.close(); infModel.close(); model.close(); dataset.close(); } 

Is there something wrong with the code above, or what else could be causing it to not work?

In addition, I would like to know if I can increase productivity if I do “Export alleged axioms as an ontology” (as provided by Protege)?

EDIT: In the meantime, I'm trying to use Pellet, but still I can't get the intended model, as I described in my other question: OutOfMemoryError using Pellet as Reasoner . So what else can I do?

+6
source share
1 answer

As far as performance is concerned, it is better to draw a conclusion before approving the data, and not to do SPARQL with the Jena output mechanism. You are already using TDB, which is the right Jena component for large datasets.

If you don’t get the expected performance when using the output, I recommend switching to a more scalable triple storage ( 4store or Virtuoso ).

+3
source

Source: https://habr.com/ru/post/913362/


All Articles