You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Abduladem Eljamel <a_...@yahoo.co.uk.INVALID> on 2016/04/14 16:17:24 UTC

Reasoning On Graphs

Hi,,
I have a DBT dataset contains several named graphs and ontology file. I would like to apply the same reasoning on all graphs in the dataset. 
I tried this code to apply reasoning on one named graph.   

OntModel ontmodel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM, null);
File filePath = new File(OntologyPath);
URL filePathURL = filePath.toURI().toURL();
ontmodel.read(filePathURL.toString());

Dataset dataset = TDBFactory.createDataset(datasetLocation);
dataset.begin(ReadWrite.WRITE) ;
Model model = dataset.getNamedModel(graphName);

Reasoner reasoner = ReasonerRegistry.getOWLMicroReasoner();
reasoner= reasoner.bindSchema(ontmodel);
InfModel infmodel = ModelFactory.createInfModel(reasoner, model);

Should I apply the reasoning on the graphs one by one? Is there any method to apply the reasoning on all graphs and they stay separate as they are? Is there any method which can be used as for the default graphs below?

Model model = dataset.getDefaultModel();

Thanks
Abdul

  

Re: Chained Properties

Posted by Dave Reynolds <da...@gmail.com>.
On 15/04/16 12:12, Abduladem Eljamel wrote:
> HiDoes the reasoning engine in Jena supports the chained propertiesrules of OWL2?ThanksAbdul

No, there's no support for OWL2 builtin.

Dave



Chained Properties

Posted by Abduladem Eljamel <a_...@yahoo.co.uk.INVALID>.
HiDoes the reasoning engine in Jena supports the chained propertiesrules of OWL2?ThanksAbdul


   

Re: Reasoning On Graphs

Posted by Dave Reynolds <da...@gmail.com>.
On 14/04/16 15:17, Abduladem Eljamel wrote:
> Hi,,
> I have a DBT dataset contains several named graphs and ontology file. I would like to apply the same reasoning on all graphs in the dataset.

The Jena reasoner is not dataset-aware, it only works over models.

The reasoner also only works in memory, you can run it over a TDB-backed 
model but the results will be stored in memory and will not  persist 
unless you explicitly write them out to a persisted model.

> I tried this code to apply reasoning on one named graph.
>
> OntModel ontmodel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM, null);
> File filePath = new File(OntologyPath);
> URL filePathURL = filePath.toURI().toURL();
> ontmodel.read(filePathURL.toString());
>
> Dataset dataset = TDBFactory.createDataset(datasetLocation);
> dataset.begin(ReadWrite.WRITE) ;

No need for this, you are not writing to the dataset here.

> Model model = dataset.getNamedModel(graphName);
>
> Reasoner reasoner = ReasonerRegistry.getOWLMicroReasoner();
> reasoner= reasoner.bindSchema(ontmodel);
> InfModel infmodel = ModelFactory.createInfModel(reasoner, model);

This will work but, as noted above, the infmodel is in memory and it has 
to do quite a bit of work to load the data from TDB. It can be more 
efficient to just load the TDB model into an in memory model first and 
create the infmodel over that.

> Should I apply the reasoning on the graphs one by one? Is there any method to apply the reasoning on all graphs and they stay separate as they are? Is there any method which can be used as for the default graphs below?
>
> Model model = dataset.getDefaultModel();

Not sure I follow the question.

If you want to be able to access each of the inference closures of each 
of the source graphs separately then you will need an InfModel for each.

If you want to treat the set of graphs as one big graph, and create a 
single inference closure over the union model then do that. You can 
either configure TDB to have the defaultGraph be the union of all the 
named graphs or you can use the TDB-specific name for the union 
urn:x-arq:DefaultGraph.

Dave