You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Guilherme Maranhão <gu...@gmail.com> on 2014/02/19 04:20:42 UTC

Problem on instantiating an OntClass object

Hello guys,

Those are the steps I am using to instantiate an OntClass object:

// modelMem is an OntModel object.
1 - Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
2 - reasoner = reasoner.bindSchema(modelMem);
3 - OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
4 - ontModelSpec.setReasoner(reasoner);
5 - OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
modelMem);
6 - OntClass stage3Hypertension = ontModel.getOntClass("
http://www.semanticweb.org/ontologies/2013/1/Ontology1361391792831.owl#Stage3Hypertension
");

After line 2, the console prompt shows a lot of warning messages, like this:

Fev 19, 2014 12:15:56 AM
org.mindswap.pellet.jena.graph.query.GraphQueryHandler findTriple
Warning: No query handler found for
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.w3.org/1999/02/22-rdf-syntax-ns#Property

After line 6, again a lot of warning messages are shown, like this:

Fev 19, 2014 12:18:12 AM
org.mindswap.pellet.jena.graph.query.GraphQueryHandler findTriple
Warning: No query handler found for
http://www.w3.org/2000/01/rdf-schema#Class urn:x-hp-jena:rubrik/xsdRange *

And then, stage3Hypertension isn't instantiated, keeping null.

What am I missing?
Is there anything to do with the reasoner engine I am using, that maybe
does not support the ontology's properties?
Or the fact that the URI
http://www.semanticweb.org/ontologies/2013/1/Ontology1361391792831.owl#Stage3Hypertension
returns
404 Error? Should I use the local path to refer to the ontology class?

Any hint?

Thanks,

Guilherme

Re: Problem on instantiating an OntClass object

Posted by Guilherme Maranhão <gu...@gmail.com>.
Hi Dave,

I did not try model.read (ontPath, "RDF/XML").

I need to create the ontology with the Pellet Reasoner specification,
because I need to make some inferences based on the ontology's SWRL rules.

Thanks!


On Thu, Feb 20, 2014 at 5:24 AM, Dave Reynolds <da...@gmail.com>wrote:

> On 20/02/14 02:07, Guilherme Maranhão wrote:
>
>> Hi Dave,
>>
>> I've tried all the possible ways to simply create a model and none did
>> work.
>>
>> I've tried your last suggestion and it sends file not found. I've tried
>> with both absolute and relative paths.
>>
>
> In that case you need to figure out the right file name. You might want to
> start with something simple such as putting the data file in the same place
> you are running the code then work up from there.
>
>
>  Another way I have tried is as follows:
>>
>> OntModel model = ModelFactory.createOntologyModel(
>> PelletReasonerFactory.THE
>> proj_SPEC, null );
>>
>
> That's creating a model with a Pellet reasoner. If that's what you want
> then great. But especially if are having problems getting started then you
> might want to start without inference and work up.
>
> OntModel model
>    = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
>
>
>  model.read( ontPath, "RDF/XML" );
>>
>> ontPath is relative to my project path.
>>
>
> And did that work?
>
> Dave
>
>
>
>> I am very new to Jena, that's why I am having these kind of difficulties.
>>
>> Thanks again,
>>
>> Guilherme
>>
>>
>> On Wed, Feb 19, 2014 at 11:18 AM, Dave Reynolds
>> <da...@gmail.com>wrote:
>>
>>  On 19/02/14 11:54, Guilherme Maranhão wrote:
>>>
>>>  Dave,
>>>>
>>>> I've removed line 2 as you've suggested, but stage3Hypertension
>>>> continues
>>>> null.
>>>>
>>>> Isn't it the way I am creating the modelMem object?
>>>>
>>>> ModelMaker modelMaker = ModelFactory.createFileModelMaker(/User/
>>>> guilherme
>>>> /ontology/vitalSign.owl);
>>>> Model modeltmp = modelMaker.createDefaultModel();
>>>> modelMem = ModelFactory.createOntologyModel(OntModelSpec.
>>>> OWL_MEM_MICRO_RULE_INF, modeltmp);
>>>>
>>>>
>>> I don't think modelMaker.createDefaultModel() loads any data, just
>>> creates an empty model. But I never use it so can't be sure.
>>>
>>> Try simply:
>>>
>>>     Model model = RDFDataMgr.loadModel("your-file-name") ;
>>>
>>> [Hope that's the right syntax, I'm still too used to FileManager.]
>>>
>>> Dave
>>>
>>>
>>>
>>>  On Wed, Feb 19, 2014 at 5:38 AM, Dave Reynolds <
>>>> dave.e.reynolds@gmail.com
>>>>
>>>>> wrote:
>>>>>
>>>>
>>>>   On 19/02/14 03:20, Guilherme Maranhão wrote:
>>>>
>>>>>
>>>>>   Hello guys,
>>>>>
>>>>>>
>>>>>> Those are the steps I am using to instantiate an OntClass object:
>>>>>>
>>>>>> // modelMem is an OntModel object.
>>>>>> 1 - Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
>>>>>> 2 - reasoner = reasoner.bindSchema(modelMem);
>>>>>> 3 - OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>>>>>> 4 - ontModelSpec.setReasoner(reasoner);
>>>>>> 5 - OntModel ontModel = ModelFactory.createOntologyModel(
>>>>>> ontModelSpec,
>>>>>> modelMem);
>>>>>> 6 - OntClass stage3Hypertension = ontModel.getOntClass("
>>>>>> http://www.semanticweb.org/ontologies/2013/1/
>>>>>> Ontology1361391792831.owl#
>>>>>> Stage3Hypertension
>>>>>> ");
>>>>>>
>>>>>>
>>>>>>  This is not your underlying problem but you have bound modelMem in
>>>>> twice
>>>>> -
>>>>> you have bound it to the reasoner and then applied that back to the
>>>>> same
>>>>> model. It would be better to just have:
>>>>>
>>>>> OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>>>>>
>>>>> OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
>>>>> modelMem);
>>>>>
>>>>> Though in fact I would recommend OWL_MEM_MICRO_RULE_INF as the best
>>>>> default.
>>>>>
>>>>>
>>>>>    After line 2, the console prompt shows a lot of warning messages,
>>>>> like
>>>>>
>>>>>  this:
>>>>>>
>>>>>> Fev 19, 2014 12:15:56 AM
>>>>>> org.mindswap.pellet.jena.graph.query.GraphQueryHandler findTriple
>>>>>> Warning: No query handler found for
>>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
>>>>>>
>>>>>>
>>>>>>  Those are messages from Pellet. Your above code does not include
>>>>> Pellet
>>>>> so
>>>>> either this isn't the code you are running or your "modelMem" in the
>>>>> above
>>>>> is actually Pellet-backed model.
>>>>>
>>>>> If the latter then you have a rule reasoner running over a rule
>>>>> reasoner
>>>>> running over Pellet. Don't know why that would cause outright failures
>>>>> but
>>>>> certainly not a useful thing to do.
>>>>>
>>>>> To get help with Pellet you would need to ask the Pellet folks, Pellet
>>>>> is
>>>>> not part of Jena.
>>>>>
>>>>> Dave
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>

Re: Problem on instantiating an OntClass object

Posted by Dave Reynolds <da...@gmail.com>.
On 20/02/14 02:07, Guilherme Maranhão wrote:
> Hi Dave,
>
> I've tried all the possible ways to simply create a model and none did work.
>
> I've tried your last suggestion and it sends file not found. I've tried
> with both absolute and relative paths.

In that case you need to figure out the right file name. You might want 
to start with something simple such as putting the data file in the same 
place you are running the code then work up from there.

> Another way I have tried is as follows:
>
> OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE
> proj_SPEC, null );

That's creating a model with a Pellet reasoner. If that's what you want 
then great. But especially if are having problems getting started then 
you might want to start without inference and work up.

OntModel model
    = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );

> model.read( ontPath, "RDF/XML" );
>
> ontPath is relative to my project path.

And did that work?

Dave

>
> I am very new to Jena, that's why I am having these kind of difficulties.
>
> Thanks again,
>
> Guilherme
>
>
> On Wed, Feb 19, 2014 at 11:18 AM, Dave Reynolds
> <da...@gmail.com>wrote:
>
>> On 19/02/14 11:54, Guilherme Maranhão wrote:
>>
>>> Dave,
>>>
>>> I've removed line 2 as you've suggested, but stage3Hypertension continues
>>> null.
>>>
>>> Isn't it the way I am creating the modelMem object?
>>>
>>> ModelMaker modelMaker = ModelFactory.createFileModelMaker(/User/guilherme
>>> /ontology/vitalSign.owl);
>>> Model modeltmp = modelMaker.createDefaultModel();
>>> modelMem = ModelFactory.createOntologyModel(OntModelSpec.
>>> OWL_MEM_MICRO_RULE_INF, modeltmp);
>>>
>>
>> I don't think modelMaker.createDefaultModel() loads any data, just
>> creates an empty model. But I never use it so can't be sure.
>>
>> Try simply:
>>
>>     Model model = RDFDataMgr.loadModel("your-file-name") ;
>>
>> [Hope that's the right syntax, I'm still too used to FileManager.]
>>
>> Dave
>>
>>
>>
>>> On Wed, Feb 19, 2014 at 5:38 AM, Dave Reynolds <dave.e.reynolds@gmail.com
>>>> wrote:
>>>
>>>   On 19/02/14 03:20, Guilherme Maranhão wrote:
>>>>
>>>>   Hello guys,
>>>>>
>>>>> Those are the steps I am using to instantiate an OntClass object:
>>>>>
>>>>> // modelMem is an OntModel object.
>>>>> 1 - Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
>>>>> 2 - reasoner = reasoner.bindSchema(modelMem);
>>>>> 3 - OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>>>>> 4 - ontModelSpec.setReasoner(reasoner);
>>>>> 5 - OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
>>>>> modelMem);
>>>>> 6 - OntClass stage3Hypertension = ontModel.getOntClass("
>>>>> http://www.semanticweb.org/ontologies/2013/1/Ontology1361391792831.owl#
>>>>> Stage3Hypertension
>>>>> ");
>>>>>
>>>>>
>>>> This is not your underlying problem but you have bound modelMem in twice
>>>> -
>>>> you have bound it to the reasoner and then applied that back to the same
>>>> model. It would be better to just have:
>>>>
>>>> OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>>>>
>>>> OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
>>>> modelMem);
>>>>
>>>> Though in fact I would recommend OWL_MEM_MICRO_RULE_INF as the best
>>>> default.
>>>>
>>>>
>>>>    After line 2, the console prompt shows a lot of warning messages, like
>>>>
>>>>> this:
>>>>>
>>>>> Fev 19, 2014 12:15:56 AM
>>>>> org.mindswap.pellet.jena.graph.query.GraphQueryHandler findTriple
>>>>> Warning: No query handler found for
>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
>>>>>
>>>>>
>>>> Those are messages from Pellet. Your above code does not include Pellet
>>>> so
>>>> either this isn't the code you are running or your "modelMem" in the
>>>> above
>>>> is actually Pellet-backed model.
>>>>
>>>> If the latter then you have a rule reasoner running over a rule reasoner
>>>> running over Pellet. Don't know why that would cause outright failures
>>>> but
>>>> certainly not a useful thing to do.
>>>>
>>>> To get help with Pellet you would need to ask the Pellet folks, Pellet is
>>>> not part of Jena.
>>>>
>>>> Dave
>>>>
>>>>
>>>>
>>>
>>
>


Re: Problem on instantiating an OntClass object

Posted by Guilherme Maranhão <gu...@gmail.com>.
Hi Dave,

I finally did it!

OntModel ontModel = ModelFactory.createOntologyModel( PelletReasonerFactory.
THE_SPEC );
FileManager.get().getLocationMapper().addAltEntry( SOURCE_URL, SOURCE_FILE);
Model baseOntology = FileManager.get().loadModel( SOURCE_FILE );
ontModel.addSubModel( baseOntology );

I was not declaring the source_file relatively, like this "./scr/..." ,
with the *dot* in the beginning.

Everything is ok now.

Thanks a lot,

Guilherme





On Wed, Feb 19, 2014 at 11:07 PM, Guilherme Maranhão
<gu...@gmail.com>wrote:

> Hi Dave,
>
> I've tried all the possible ways to simply create a model and none did
> work.
>
> I've tried your last suggestion and it sends file not found. I've tried
> with both absolute and relative paths.
>
> Another way I have tried is as follows:
>
> OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE
> proj_SPEC, null );
> model.read( ontPath, "RDF/XML" );
>
> ontPath is relative to my project path.
>
> I am very new to Jena, that's why I am having these kind of difficulties.
>
> Thanks again,
>
> Guilherme
>
>
> On Wed, Feb 19, 2014 at 11:18 AM, Dave Reynolds <dave.e.reynolds@gmail.com
> > wrote:
>
>> On 19/02/14 11:54, Guilherme Maranhão wrote:
>>
>>> Dave,
>>>
>>> I've removed line 2 as you've suggested, but stage3Hypertension continues
>>> null.
>>>
>>> Isn't it the way I am creating the modelMem object?
>>>
>>> ModelMaker modelMaker = ModelFactory.createFileModelMaker(/User/
>>> guilherme
>>> /ontology/vitalSign.owl);
>>> Model modeltmp = modelMaker.createDefaultModel();
>>> modelMem = ModelFactory.createOntologyModel(OntModelSpec.
>>> OWL_MEM_MICRO_RULE_INF, modeltmp);
>>>
>>
>> I don't think modelMaker.createDefaultModel() loads any data, just
>> creates an empty model. But I never use it so can't be sure.
>>
>> Try simply:
>>
>>    Model model = RDFDataMgr.loadModel("your-file-name") ;
>>
>> [Hope that's the right syntax, I'm still too used to FileManager.]
>>
>> Dave
>>
>>
>>
>>> On Wed, Feb 19, 2014 at 5:38 AM, Dave Reynolds <
>>> dave.e.reynolds@gmail.com>wrote:
>>>
>>>  On 19/02/14 03:20, Guilherme Maranhão wrote:
>>>>
>>>>  Hello guys,
>>>>>
>>>>> Those are the steps I am using to instantiate an OntClass object:
>>>>>
>>>>> // modelMem is an OntModel object.
>>>>> 1 - Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
>>>>> 2 - reasoner = reasoner.bindSchema(modelMem);
>>>>> 3 - OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>>>>> 4 - ontModelSpec.setReasoner(reasoner);
>>>>> 5 - OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
>>>>> modelMem);
>>>>> 6 - OntClass stage3Hypertension = ontModel.getOntClass("
>>>>> http://www.semanticweb.org/ontologies/2013/1/
>>>>> Ontology1361391792831.owl#
>>>>> Stage3Hypertension
>>>>> ");
>>>>>
>>>>>
>>>> This is not your underlying problem but you have bound modelMem in
>>>> twice -
>>>> you have bound it to the reasoner and then applied that back to the same
>>>> model. It would be better to just have:
>>>>
>>>> OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>>>>
>>>> OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
>>>> modelMem);
>>>>
>>>> Though in fact I would recommend OWL_MEM_MICRO_RULE_INF as the best
>>>> default.
>>>>
>>>>
>>>>   After line 2, the console prompt shows a lot of warning messages, like
>>>>
>>>>> this:
>>>>>
>>>>> Fev 19, 2014 12:15:56 AM
>>>>> org.mindswap.pellet.jena.graph.query.GraphQueryHandler findTriple
>>>>> Warning: No query handler found for
>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
>>>>>
>>>>>
>>>> Those are messages from Pellet. Your above code does not include Pellet
>>>> so
>>>> either this isn't the code you are running or your "modelMem" in the
>>>> above
>>>> is actually Pellet-backed model.
>>>>
>>>> If the latter then you have a rule reasoner running over a rule reasoner
>>>> running over Pellet. Don't know why that would cause outright failures
>>>> but
>>>> certainly not a useful thing to do.
>>>>
>>>> To get help with Pellet you would need to ask the Pellet folks, Pellet
>>>> is
>>>> not part of Jena.
>>>>
>>>> Dave
>>>>
>>>>
>>>>
>>>
>>
>

Re: Problem on instantiating an OntClass object

Posted by Guilherme Maranhão <gu...@gmail.com>.
Hi Dave,

I've tried all the possible ways to simply create a model and none did work.

I've tried your last suggestion and it sends file not found. I've tried
with both absolute and relative paths.

Another way I have tried is as follows:

OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE
proj_SPEC, null );
model.read( ontPath, "RDF/XML" );

ontPath is relative to my project path.

I am very new to Jena, that's why I am having these kind of difficulties.

Thanks again,

Guilherme


On Wed, Feb 19, 2014 at 11:18 AM, Dave Reynolds
<da...@gmail.com>wrote:

> On 19/02/14 11:54, Guilherme Maranhão wrote:
>
>> Dave,
>>
>> I've removed line 2 as you've suggested, but stage3Hypertension continues
>> null.
>>
>> Isn't it the way I am creating the modelMem object?
>>
>> ModelMaker modelMaker = ModelFactory.createFileModelMaker(/User/guilherme
>> /ontology/vitalSign.owl);
>> Model modeltmp = modelMaker.createDefaultModel();
>> modelMem = ModelFactory.createOntologyModel(OntModelSpec.
>> OWL_MEM_MICRO_RULE_INF, modeltmp);
>>
>
> I don't think modelMaker.createDefaultModel() loads any data, just
> creates an empty model. But I never use it so can't be sure.
>
> Try simply:
>
>    Model model = RDFDataMgr.loadModel("your-file-name") ;
>
> [Hope that's the right syntax, I'm still too used to FileManager.]
>
> Dave
>
>
>
>> On Wed, Feb 19, 2014 at 5:38 AM, Dave Reynolds <dave.e.reynolds@gmail.com
>> >wrote:
>>
>>  On 19/02/14 03:20, Guilherme Maranhão wrote:
>>>
>>>  Hello guys,
>>>>
>>>> Those are the steps I am using to instantiate an OntClass object:
>>>>
>>>> // modelMem is an OntModel object.
>>>> 1 - Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
>>>> 2 - reasoner = reasoner.bindSchema(modelMem);
>>>> 3 - OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>>>> 4 - ontModelSpec.setReasoner(reasoner);
>>>> 5 - OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
>>>> modelMem);
>>>> 6 - OntClass stage3Hypertension = ontModel.getOntClass("
>>>> http://www.semanticweb.org/ontologies/2013/1/Ontology1361391792831.owl#
>>>> Stage3Hypertension
>>>> ");
>>>>
>>>>
>>> This is not your underlying problem but you have bound modelMem in twice
>>> -
>>> you have bound it to the reasoner and then applied that back to the same
>>> model. It would be better to just have:
>>>
>>> OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>>>
>>> OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
>>> modelMem);
>>>
>>> Though in fact I would recommend OWL_MEM_MICRO_RULE_INF as the best
>>> default.
>>>
>>>
>>>   After line 2, the console prompt shows a lot of warning messages, like
>>>
>>>> this:
>>>>
>>>> Fev 19, 2014 12:15:56 AM
>>>> org.mindswap.pellet.jena.graph.query.GraphQueryHandler findTriple
>>>> Warning: No query handler found for
>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
>>>>
>>>>
>>> Those are messages from Pellet. Your above code does not include Pellet
>>> so
>>> either this isn't the code you are running or your "modelMem" in the
>>> above
>>> is actually Pellet-backed model.
>>>
>>> If the latter then you have a rule reasoner running over a rule reasoner
>>> running over Pellet. Don't know why that would cause outright failures
>>> but
>>> certainly not a useful thing to do.
>>>
>>> To get help with Pellet you would need to ask the Pellet folks, Pellet is
>>> not part of Jena.
>>>
>>> Dave
>>>
>>>
>>>
>>
>

Re: Problem on instantiating an OntClass object

Posted by Dave Reynolds <da...@gmail.com>.
On 19/02/14 11:54, Guilherme Maranhão wrote:
> Dave,
>
> I've removed line 2 as you've suggested, but stage3Hypertension continues
> null.
>
> Isn't it the way I am creating the modelMem object?
>
> ModelMaker modelMaker = ModelFactory.createFileModelMaker(/User/guilherme
> /ontology/vitalSign.owl);
> Model modeltmp = modelMaker.createDefaultModel();
> modelMem = ModelFactory.createOntologyModel(OntModelSpec.
> OWL_MEM_MICRO_RULE_INF, modeltmp);

I don't think modelMaker.createDefaultModel() loads any data, just 
creates an empty model. But I never use it so can't be sure.

Try simply:

    Model model = RDFDataMgr.loadModel("your-file-name") ;

[Hope that's the right syntax, I'm still too used to FileManager.]

Dave

>
> On Wed, Feb 19, 2014 at 5:38 AM, Dave Reynolds <da...@gmail.com>wrote:
>
>> On 19/02/14 03:20, Guilherme Maranhão wrote:
>>
>>> Hello guys,
>>>
>>> Those are the steps I am using to instantiate an OntClass object:
>>>
>>> // modelMem is an OntModel object.
>>> 1 - Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
>>> 2 - reasoner = reasoner.bindSchema(modelMem);
>>> 3 - OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>>> 4 - ontModelSpec.setReasoner(reasoner);
>>> 5 - OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
>>> modelMem);
>>> 6 - OntClass stage3Hypertension = ontModel.getOntClass("
>>> http://www.semanticweb.org/ontologies/2013/1/Ontology1361391792831.owl#
>>> Stage3Hypertension
>>> ");
>>>
>>
>> This is not your underlying problem but you have bound modelMem in twice -
>> you have bound it to the reasoner and then applied that back to the same
>> model. It would be better to just have:
>>
>> OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>>
>> OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
>> modelMem);
>>
>> Though in fact I would recommend OWL_MEM_MICRO_RULE_INF as the best
>> default.
>>
>>
>>   After line 2, the console prompt shows a lot of warning messages, like
>>> this:
>>>
>>> Fev 19, 2014 12:15:56 AM
>>> org.mindswap.pellet.jena.graph.query.GraphQueryHandler findTriple
>>> Warning: No query handler found for
>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
>>>
>>
>> Those are messages from Pellet. Your above code does not include Pellet so
>> either this isn't the code you are running or your "modelMem" in the above
>> is actually Pellet-backed model.
>>
>> If the latter then you have a rule reasoner running over a rule reasoner
>> running over Pellet. Don't know why that would cause outright failures but
>> certainly not a useful thing to do.
>>
>> To get help with Pellet you would need to ask the Pellet folks, Pellet is
>> not part of Jena.
>>
>> Dave
>>
>>
>


Re: Problem on instantiating an OntClass object

Posted by Guilherme Maranhão <gu...@gmail.com>.
Dave,

I've removed line 2 as you've suggested, but stage3Hypertension continues
null.

Isn't it the way I am creating the modelMem object?

ModelMaker modelMaker = ModelFactory.createFileModelMaker(/User/guilherme
/ontology/vitalSign.owl);
Model modeltmp = modelMaker.createDefaultModel();
modelMem = ModelFactory.createOntologyModel(OntModelSpec.
OWL_MEM_MICRO_RULE_INF, modeltmp);

thanks,

Guilherme






On Wed, Feb 19, 2014 at 5:38 AM, Dave Reynolds <da...@gmail.com>wrote:

> On 19/02/14 03:20, Guilherme Maranhão wrote:
>
>> Hello guys,
>>
>> Those are the steps I am using to instantiate an OntClass object:
>>
>> // modelMem is an OntModel object.
>> 1 - Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
>> 2 - reasoner = reasoner.bindSchema(modelMem);
>> 3 - OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>> 4 - ontModelSpec.setReasoner(reasoner);
>> 5 - OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
>> modelMem);
>> 6 - OntClass stage3Hypertension = ontModel.getOntClass("
>> http://www.semanticweb.org/ontologies/2013/1/Ontology1361391792831.owl#
>> Stage3Hypertension
>> ");
>>
>
> This is not your underlying problem but you have bound modelMem in twice -
> you have bound it to the reasoner and then applied that back to the same
> model. It would be better to just have:
>
> OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
>
> OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
> modelMem);
>
> Though in fact I would recommend OWL_MEM_MICRO_RULE_INF as the best
> default.
>
>
>  After line 2, the console prompt shows a lot of warning messages, like
>> this:
>>
>> Fev 19, 2014 12:15:56 AM
>> org.mindswap.pellet.jena.graph.query.GraphQueryHandler findTriple
>> Warning: No query handler found for
>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>> http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
>>
>
> Those are messages from Pellet. Your above code does not include Pellet so
> either this isn't the code you are running or your "modelMem" in the above
> is actually Pellet-backed model.
>
> If the latter then you have a rule reasoner running over a rule reasoner
> running over Pellet. Don't know why that would cause outright failures but
> certainly not a useful thing to do.
>
> To get help with Pellet you would need to ask the Pellet folks, Pellet is
> not part of Jena.
>
> Dave
>
>

Re: Problem on instantiating an OntClass object

Posted by Dave Reynolds <da...@gmail.com>.
On 19/02/14 03:20, Guilherme Maranhão wrote:
> Hello guys,
>
> Those are the steps I am using to instantiate an OntClass object:
>
> // modelMem is an OntModel object.
> 1 - Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
> 2 - reasoner = reasoner.bindSchema(modelMem);
> 3 - OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
> 4 - ontModelSpec.setReasoner(reasoner);
> 5 - OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec,
> modelMem);
> 6 - OntClass stage3Hypertension = ontModel.getOntClass("
> http://www.semanticweb.org/ontologies/2013/1/Ontology1361391792831.owl#Stage3Hypertension
> ");

This is not your underlying problem but you have bound modelMem in twice 
- you have bound it to the reasoner and then applied that back to the 
same model. It would be better to just have:

OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec, 
modelMem);

Though in fact I would recommend OWL_MEM_MICRO_RULE_INF as the best default.

> After line 2, the console prompt shows a lot of warning messages, like this:
>
> Fev 19, 2014 12:15:56 AM
> org.mindswap.pellet.jena.graph.query.GraphQueryHandler findTriple
> Warning: No query handler found for
> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> http://www.w3.org/1999/02/22-rdf-syntax-ns#Property

Those are messages from Pellet. Your above code does not include Pellet 
so either this isn't the code you are running or your "modelMem" in the 
above is actually Pellet-backed model.

If the latter then you have a rule reasoner running over a rule reasoner 
running over Pellet. Don't know why that would cause outright failures 
but certainly not a useful thing to do.

To get help with Pellet you would need to ask the Pellet folks, Pellet 
is not part of Jena.

Dave